diff --git a/app/PdeBase.java b/app/PdeBase.java index 87da07863..1e6d5a0c4 100644 --- a/app/PdeBase.java +++ b/app/PdeBase.java @@ -38,6 +38,8 @@ import javax.swing.undo.*; import com.apple.mrj.*; import com.ice.jni.registry.*; +import processing.core.*; + /** * Primary role of this class is for platform identification and @@ -45,32 +47,41 @@ import com.ice.jni.registry.*; * files and images, etc) that comes from that. */ public class PdeBase { - static final String VERSION = "0080 Alpha"; + static final String VERSION = "0081 Alpha"; + /** + * Path of filename opened on the command line, + * or via the MRJ open document handler. + */ static String openedAtStartup; - //static ClassLoader loader; - PdeEditor editor; - static final int WINDOWS = 1; - static final int MACOS9 = 2; - static final int MACOSX = 3; - static final int LINUX = 4; - static final int IRIX = 5; - static final int UNKNOWN = 5; - static int platform; - - static final String platforms[] = { - "", "windows", "macos9", "macosx", "linux", "irix" - }; - static public void main(String args[]) { + + // make sure that this is running on java 1.4 + + if (PApplet.JDK_VERSION < 1.4) { + //System.err.println("no way man"); + PdeBase.showError("Need to install Java 1.4", + "This version of Processing requires \n" + + "Java 1.4 or later to run properly.\n" + + "Please visit java.com to upgrade.", null); + } + + + // grab any opened file from the command line + if (args.length == 1) { PdeBase.openedAtStartup = args[0]; } + + // register a temporary/early version of the mrj open document handler, + // because the event may be lost (sometimes, not always) by the time + // that PdeEditor is properly constructed. + MRJOpenDocumentHandler startupOpen = new MRJOpenDocumentHandler() { public void handleOpenFile(File file) { // this will only get set once.. later will be handled @@ -88,36 +99,11 @@ public class PdeBase { public PdeBase() { - // figure out which operating system - // this has to be first, since editor needs to know - - if (System.getProperty("mrj.version") != null) { // running on a mac - platform = (System.getProperty("os.name").equals("Mac OS X")) ? - MACOSX : MACOS9; - - } else { - String osname = System.getProperty("os.name"); - - if (osname.indexOf("Windows") != -1) { - platform = WINDOWS; - - } else if (osname.equals("Linux")) { // true for the ibm vm - platform = LINUX; - - } else if (osname.equals("Irix")) { - platform = IRIX; - - } else { - platform = UNKNOWN; - //System.out.println("unhandled osname: \"" + osname + "\""); - } - } - // set the look and feel before opening the window try { - if (platform == LINUX) { + if (PdeBase.isLinux()) { // linux is by default (motif?) even uglier than metal // actually, i'm using native menus, so they're ugly and // motif-looking. ick. need to fix this. @@ -141,10 +127,34 @@ public class PdeBase { // show the window editor.show(); + } - // maybe? - //loader = new PdeClassLoader(); + // ................................................................. + + + /** + * returns true if the Processing is running on a Mac OS machine, + * specifically a Mac OS X machine because it doesn't un on OS 9 anymore. + */ + static public boolean isMacOS() { + return PApplet.platform == PConstants.MACOSX; + } + + + /** + * returns true if running on windows. + */ + static public boolean isWindows() { + return PApplet.platform == PConstants.WINDOWS; + } + + + /** + * true if running on linux. + */ + static public boolean isLinux() { + return PApplet.platform == PConstants.LINUX; } @@ -167,7 +177,7 @@ public class PdeBase { if (pref != null) { dataFolder = new File(pref); - } else if (platform == MACOSX) { + } else if (PdeBase.isMacOS()) { // carbon folder constants // http://developer.apple.com/documentation/Carbon/Reference // /Folder_Manager/folder_manager_ref/constant_6.html#/ @@ -213,7 +223,7 @@ public class PdeBase { "Error getting the Processing data folder.", e); } - } else if (platform == WINDOWS) { + } else if (PdeBase.isWindows()) { // looking for Documents and Settings/blah/Application Data/Processing // this is just based on the other documentation, and eyeballing @@ -306,7 +316,7 @@ public class PdeBase { static public File getDefaultSketchbookFolder() { File sketchbookFolder = null; - if (platform == MACOSX) { + if (PdeBase.isMacOS()) { // looking for /Users/blah/Documents/Processing // carbon folder constants @@ -340,7 +350,7 @@ public class PdeBase { "Could not locate default sketch folder location.", e); } - } else if (platform == WINDOWS) { + } else if (isWindows()) { // looking for Documents and Settings/blah/My Documents/Processing // (though using a reg key since it's different on other platforms) @@ -462,7 +472,7 @@ public class PdeBase { static public void openURL(String url) { //System.out.println("opening url " + url); try { - if (platform == WINDOWS) { + if (PdeBase.isWindows()) { // this is not guaranteed to work, because who knows if the // path will always be c:\progra~1 et al. also if the user has // a different browser set as their default (which would @@ -491,7 +501,7 @@ public class PdeBase { Runtime.getRuntime().exec("cmd /c \"" + url + "\""); } - } else if (platform == MACOSX) { + } else if (PdeBase.isMacOS()) { //com.apple.eio.FileManager.openURL(url); if (!url.startsWith("http://")) { @@ -518,10 +528,10 @@ public class PdeBase { //System.out.println("trying to open " + url); com.apple.mrj.MRJFileUtils.openURL(url); - } else if (platform == MACOS9) { - com.apple.mrj.MRJFileUtils.openURL(url); + //} else if (platform == MACOS9) { + //com.apple.mrj.MRJFileUtils.openURL(url); - } else if (platform == LINUX) { + } else if (PdeBase.isLinux()) { // how's mozilla sound to ya, laddie? //Runtime.getRuntime().exec(new String[] { "mozilla", url }); String browser = PdePreferences.get("browser"); @@ -548,7 +558,7 @@ public class PdeBase { try { String folder = file.getAbsolutePath(); - if (platform == WINDOWS) { + if (PdeBase.isWindows()) { // doesn't work //Runtime.getRuntime().exec("cmd /c \"" + folder + "\""); @@ -558,7 +568,7 @@ public class PdeBase { // not tested //Runtime.getRuntime().exec("start explorer \"" + folder + "\""); - } else if (platform == MACOSX) { + } else if (PdeBase.isMacOS()) { openURL(folder); // handles char replacement, etc } diff --git a/app/PdeCompiler.java b/app/PdeCompiler.java index dff3cc894..528f5df05 100644 --- a/app/PdeCompiler.java +++ b/app/PdeCompiler.java @@ -74,7 +74,7 @@ public class PdeCompiler implements PdeMessageConsumer { // 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" : + ((!PdeBase.isMacOS()) ? "jikes" : System.getProperty("user.dir") + File.separator + "jikes"), // this doesn't help much.. also java 1.4 seems to not support @@ -359,7 +359,7 @@ public class PdeCompiler implements PdeMessageConsumer { static public String calcBootClassPath() { if (bootClassPath == null) { String additional = ""; - if (PdeBase.platform == PdeBase.MACOSX) { + if (PdeBase.isMacOS()) { additional = contentsToClassPath(new File("/System/Library/Java/Extensions/")); } diff --git a/app/PdeEditor.java b/app/PdeEditor.java index 26da24a83..a0c918dd1 100644 --- a/app/PdeEditor.java +++ b/app/PdeEditor.java @@ -46,7 +46,7 @@ public class PdeEditor extends JFrame MRJOpenDocumentHandler //, MRJOpenApplicationHandler { // yeah - static final String WINDOW_TITLE = "Processing"; + static final String WINDOW_TITLE = "Processing" + " - " + PdeBase.VERSION; // p5 icon for the window Image icon; @@ -58,6 +58,9 @@ public class PdeEditor extends JFrame " " + " "; + static public final KeyStroke WINDOW_CLOSE_KEYSTROKE = + KeyStroke.getKeyStroke('W', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()); + static final int HANDLE_NEW = 1; static final int HANDLE_OPEN = 2; static final int HANDLE_QUIT = 3; @@ -65,8 +68,6 @@ public class PdeEditor extends JFrame String handleOpenPath; boolean handleNewShift; boolean handleNewLibrary; - //String handleSaveAsPath; - //String openingName; PdeEditorButtons buttons; PdeEditorHeader header; @@ -88,22 +89,14 @@ public class PdeEditor extends JFrame // runtime information and window placement Point appletLocation; - Point presentLocation; - Window presentationWindow; + //Point presentLocation; + //Window presentationWindow; RunButtonWatcher watcher; PdeRuntime runtime; - //boolean externalRuntime; - //String externalPaths; - //File externalCode; - JMenuItem exportAppItem; JMenuItem saveMenuItem; JMenuItem saveAsMenuItem; - //JMenuItem beautifyMenuItem; - - JRadioButtonMenuItem coreRendererItem; - JRadioButtonMenuItem openglRendererItem; // @@ -120,14 +113,14 @@ public class PdeEditor extends JFrame //PdeHistory history; // TODO re-enable history PdeSketchbook sketchbook; - PdePreferences preferences; + //PdePreferences preferences; PdeEditorFind find; //static Properties keywords; // keyword -> reference html lookup public PdeEditor() { - super(WINDOW_TITLE + " - " + PdeBase.VERSION); + super(WINDOW_TITLE); // #@$*(@#$ apple.. always gotta think different MRJApplicationUtils.registerAboutHandler(this); @@ -135,8 +128,8 @@ public class PdeEditor extends JFrame MRJApplicationUtils.registerQuitHandler(this); MRJApplicationUtils.registerOpenDocumentHandler(this); - // this is needed by just about everything else - preferences = new PdePreferences(); + // run static initialization that grabs all the prefs + PdePreferences.init(); // set the window icon try { @@ -240,7 +233,7 @@ public class PdeEditor extends JFrame // to fix ugliness.. normally macosx java 1.3 puts an // ugly white border around this object, so turn it off. - if (PdeBase.platform == PdeBase.MACOSX) { + if (PdeBase.isMacOS()) { splitPane.setBorder(null); } @@ -274,9 +267,9 @@ public class PdeEditor extends JFrame Document document = textarea.getDocument(); document.addUndoableEditListener(new PdeUndoableEditListener()); + /* Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); - if ((PdeBase.platform == PdeBase.MACOSX) || - (PdeBase.platform == PdeBase.MACOS9)) { + if (PdeBase.isMacOS()) { presentationWindow = new Frame(); // mrj is still (with version 2.2.x) a piece of shit, @@ -291,17 +284,7 @@ public class PdeEditor extends JFrame screen.height + insets.top + insets.bottom); } else { presentationWindow = new Frame(); - //((Frame)presentationWindow).setUndecorated(true); - try { - Method undecoratedMethod = - Frame.class.getMethod("setUndecorated", - new Class[] { Boolean.TYPE }); - undecoratedMethod.invoke(presentationWindow, - new Object[] { Boolean.TRUE }); - } catch (Exception e) { } - //} catch (NoSuchMethodException e) { } - //} catch (NoSuchMethodError e) { } - + ((Frame)presentationWindow).setUndecorated(true); presentationWindow.setBounds(0, 0, screen.width, screen.height); } @@ -358,6 +341,7 @@ public class PdeEditor extends JFrame } } }); + */ } @@ -478,6 +462,12 @@ public class PdeEditor extends JFrame textarea.setCaretVisible(true); } + // apply changes to the font size for the editor + //TextAreaPainter painter = textarea.getPainter(); + painter.setFont(PdePreferences.getFont("editor.font")); + //Font font = painter.getFont(); + //textarea.getPainter().setFont(new Font("Courier", Font.PLAIN, 36)); + // in case tab expansion stuff has changed listener.applyPreferences(); @@ -522,6 +512,15 @@ public class PdeEditor extends JFrame JMenuItem item; JMenu menu = new JMenu("File"); + /* + menu.add(item = new JMenuItem("do the editor thing")); + item.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + textarea.getPainter().setFont(new Font("Courier", Font.PLAIN, 36)); + } + }); + */ + if (!PdePreferences.getBoolean("export.library")) { item = newJMenuItem("New", 'N'); item.addActionListener(new ActionListener() { @@ -615,10 +614,10 @@ public class PdeEditor extends JFrame menu.add(item); // macosx already has its own preferences and quit menu - if (PdeBase.platform != PdeBase.MACOSX) { + if (!PdeBase.isMacOS()) { menu.addSeparator(); - item = new JMenuItem("Preferences"); + item = newJMenuItem("Preferences", ','); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { handlePrefs(); @@ -668,6 +667,7 @@ public class PdeEditor extends JFrame }); menu.add(item); + /* JMenu rendererMenu = new JMenu("Renderer"); menu.add(rendererMenu); @@ -700,6 +700,7 @@ public class PdeEditor extends JFrame boolean useOpenGL = PdePreferences.get("renderer").equals("opengl"); coreRendererItem.setSelected(!useOpenGL); openglRendererItem.setSelected(useOpenGL); + */ // @@ -717,8 +718,7 @@ public class PdeEditor extends JFrame menu.add(sketchbook.getImportMenu()); - if ((PdeBase.platform == PdeBase.WINDOWS) || - (PdeBase.platform == PdeBase.MACOSX)) { + if (PdeBase.isWindows() || PdeBase.isMacOS()) { // no way to do an 'open in file browser' on other platforms // since there isn't any sort of standard item = new JMenuItem("Show Sketch Folder"); @@ -825,7 +825,7 @@ public class PdeEditor extends JFrame menu.add(item); // macosx already has its own about menu - if (PdeBase.platform != PdeBase.MACOSX) { + if (!PdeBase.isMacOS()) { menu.addSeparator(); item = new JMenuItem("About Processing"); item.addActionListener(new ActionListener() { @@ -915,8 +915,7 @@ public class PdeEditor extends JFrame /** - * Convenience method for the antidote to overthought - * swing api mess for setting accelerators. + * Convenience method, see below. */ static public JMenuItem newJMenuItem(String title, int what) { return newJMenuItem(title, what, false); @@ -925,9 +924,9 @@ public class PdeEditor extends JFrame /** * A software engineer, somewhere, needs to have his abstraction - * taken away. I hear they jail people in third world countries for - * writing the sort of crappy api that would require a four line - * helpher function to *set the command key* for a menu item. + * taken away. In some countries they jail people for writing the + * sort of crappy api that would require a four line helper function + * to set the command key for a menu item. */ static public JMenuItem newJMenuItem(String title, int what, boolean shift) { @@ -1054,12 +1053,15 @@ public class PdeEditor extends JFrame /** - * Show the (already created on app init) preferences window. + * Show the preferences window. */ public void handlePrefs() { + PdePreferences preferences = new PdePreferences(); + preferences.showFrame(this); + // since this can't actually block, it'll hide // the editor window while the prefs are open - preferences.showFrame(this); + //preferences.showFrame(this); // and then call applyPreferences if 'ok' is hit // and then unhide @@ -1113,17 +1115,19 @@ public class PdeEditor extends JFrame } presenting = present; + /* if (presenting) { // wipe everything out with a bulbous screen-covering window presentationWindow.show(); presentationWindow.toFront(); } + */ try { if (!sketch.handleRun()) return; runtime = new PdeRuntime(sketch, PdeEditor.this); - runtime.start(presenting ? presentLocation : appletLocation); + runtime.start(appletLocation); watcher = new RunButtonWatcher(); } catch (PdeException e) { @@ -1231,20 +1235,19 @@ public class PdeEditor extends JFrame * mode, this will always be called instead of doStop(). */ public void doClose() { - if (presenting) { - presentationWindow.hide(); - - } else { - try { - // the window will also be null the process was running - // externally. so don't even try setting if window is null - // since PdeRuntime will set the appletLocation when an - // external process is in use. - if (runtime.window != null) { - appletLocation = runtime.window.getLocation(); - } - } catch (NullPointerException e) { } - } + //if (presenting) { + //presentationWindow.hide(); + //} else { + try { + // the window will also be null the process was running + // externally. so don't even try setting if window is null + // since PdeRuntime will set the appletLocation when an + // external process is in use. + if (runtime.window != null) { + appletLocation = runtime.window.getLocation(); + } + } catch (NullPointerException e) { } + //} //if (running) doStop(); doStop(); // need to stop if runtime error @@ -1642,7 +1645,7 @@ public class PdeEditor extends JFrame */ protected void handleQuit2() { storePreferences(); - preferences.save(); + PdePreferences.save(); sketchbook.clean(); diff --git a/app/PdeEditorConsole.java b/app/PdeEditorConsole.java index 6788e6eb9..1935fcb1b 100644 --- a/app/PdeEditorConsole.java +++ b/app/PdeEditorConsole.java @@ -145,7 +145,7 @@ public class PdeEditorConsole extends JScrollPane { // to fix ugliness.. normally macosx java 1.3 puts an // ugly white border around this object, so turn it off. - if (PdeBase.platform == PdeBase.MACOSX) { + if (PdeBase.isMacOS()) { setBorder(null); } } diff --git a/app/PdeEditorFind.java b/app/PdeEditorFind.java index df3b9b5b8..edefcda8e 100644 --- a/app/PdeEditorFind.java +++ b/app/PdeEditorFind.java @@ -94,8 +94,7 @@ public class PdeEditorFind extends JFrame buttons.setLayout(new FlowLayout()); // ordering is different on mac versus pc - if ((PdeBase.platform == PdeBase.MACOSX) || - (PdeBase.platform == PdeBase.MACOS9)) { + if (PdeBase.isMacOS()) { buttons.add(replaceButton = new JButton("Replace")); buttons.add(replaceAllButton = new JButton("Replace All")); buttons.add(findButton = new JButton("Find")); @@ -112,7 +111,8 @@ public class PdeEditorFind extends JFrame // to fix ugliness.. normally macosx java 1.3 puts an // ugly white border around this object, so turn it off. - if (PdeBase.platform == PdeBase.MACOSX) { + //if (PdeBase.platform == PdeBase.MACOSX) { + if (PdeBase.isMacOS()) { buttons.setBorder(null); } diff --git a/app/PdeEditorHeader.java b/app/PdeEditorHeader.java index ab63667f2..479877334 100644 --- a/app/PdeEditorHeader.java +++ b/app/PdeEditorHeader.java @@ -366,14 +366,14 @@ public class PdeEditorHeader extends JComponent { } public Dimension getMinimumSize() { - if (PdeBase.platform == PdeBase.MACOSX) { + if (PdeBase.isMacOS()) { return new Dimension(300, PdePreferences.GRID_SIZE); } return new Dimension(300, PdePreferences.GRID_SIZE - 1); } public Dimension getMaximumSize() { - if (PdeBase.platform == PdeBase.MACOSX) { + if (PdeBase.isMacOS()) { return new Dimension(3000, PdePreferences.GRID_SIZE); } return new Dimension(3000, PdePreferences.GRID_SIZE - 1); diff --git a/app/PdeEditorStatus.java b/app/PdeEditorStatus.java index 4a96fbbac..62fc30548 100644 --- a/app/PdeEditorStatus.java +++ b/app/PdeEditorStatus.java @@ -239,7 +239,7 @@ public class PdeEditorStatus extends JPanel implements ActionListener { // !@#(* aqua ui #($*(( that turtle-neck wearing #(** (#$@)( // os9 seems to work if bg of component is set, but x still a bastard - if (PdeBase.platform == PdeBase.MACOSX) { + if (PdeBase.isMacOS()) { yesButton.setBackground(bgcolor[PROMPT]); noButton.setBackground(bgcolor[PROMPT]); cancelButton.setBackground(bgcolor[PROMPT]); diff --git a/app/PdePreferences.java b/app/PdePreferences.java index 9c85b455f..abaab63e2 100644 --- a/app/PdePreferences.java +++ b/app/PdePreferences.java @@ -36,21 +36,15 @@ import javax.swing.filechooser.*; import javax.swing.text.*; import javax.swing.undo.*; +import processing.core.PApplet; -/* - need to bring all the prefs into here - PdeEditor with its sketch.properties - and PdeBase with preferences.txt - on first run: - processing.properties is created in user.home - it contains the contents of - preferences.txt + pde_platform.properties - and then begins writing additional sketch.properties stuff - - this class no longer uses the Properties class, since - properties files are iso8859-1, which is highly likely to - be a problem when trying to save sketch folders and locations +/** + * Preferences storage class. + *
+ * This class no longer uses the Properties class, since
+ * properties files are iso8859-1, which is highly likely to
+ * be a problem when trying to save sketch folders and locations.
*/
public class PdePreferences extends JComponent {
@@ -58,6 +52,14 @@ public class PdePreferences extends JComponent {
static final String PREFS_FILE = "preferences.txt";
+
+ // platform strings (used to get settings for specific platforms)
+
+ static final String platforms[] = {
+ "other", "windows", "macos9", "macosx", "linux"
+ };
+
+
// prompt text stuff
static final String PROMPT_YES = "Yes";
@@ -84,15 +86,19 @@ public class PdePreferences extends JComponent {
// gui elements
- JFrame frame;
+ //JFrame frame;
+ JDialog frame;
int wide, high;
JTextField sketchbookLocationField;
JCheckBox sketchPromptBox;
JCheckBox sketchCleanBox;
- JCheckBox exportLibraryBox;
+ //JCheckBox exportLibraryBox;
JCheckBox externalEditorBox;
+ JTextField fontSizeField;
+
+
// the calling editor, so updates can be applied
PdeEditor editor;
@@ -100,12 +106,11 @@ public class PdePreferences extends JComponent {
// data model
static Hashtable table = new Hashtable();;
-
- File preferencesFile;
+ static File preferencesFile;
//boolean firstTime; // first time this feller has been run
- public PdePreferences() {
+ static public void init() {
// start by loading the defaults, in case something
// important was deleted from the user prefs
@@ -118,10 +123,10 @@ public class PdePreferences extends JComponent {
"You'll need to reinstall Processing.", e);
}
-
// check for platform-specific properties in the defaults
- String platformExtension = "." + PdeBase.platforms[PdeBase.platform];
+ String platformExtension = "." +
+ platforms[processing.core.PApplet.platform];
int extensionLength = platformExtension.length();
Enumeration e = table.keys(); //properties.propertyNames();
@@ -167,16 +172,19 @@ public class PdePreferences extends JComponent {
" and restart Processing.", ex);
}
}
+ }
+ public PdePreferences() {
+
// setup frame for the prefs
- frame = new JFrame("Preferences");
- //frame = new JDialog("Preferences");
- frame.setResizable(false);
+ //frame = new JFrame("Preferences");
+ frame = new JDialog(editor, "Preferences", true);
+ //frame.setResizable(false);
- Container pain = this;
- //Container pain = frame.getContentPane();
+ //Container pain = this;
+ Container pain = frame.getContentPane();
pain.setLayout(null);
int top = GUI_BIG;
@@ -257,8 +265,24 @@ public class PdePreferences extends JComponent {
top += vmax + GUI_BETWEEN;
+ // Editor font size [ ]
+
+ Container box = Box.createHorizontalBox();
+ label = new JLabel("Editor font size: ");
+ box.add(label);
+ fontSizeField = new JTextField(4);
+ box.add(fontSizeField);
+ pain.add(box);
+ d = box.getPreferredSize();
+ box.setBounds(left, top, d.width, d.height);
+ Font editorFont = PdePreferences.getFont("editor.font");
+ fontSizeField.setText(String.valueOf(editorFont.getSize()));
+ top += d.height + GUI_BETWEEN;
+
+
// [ ] Enable export to "Library"
+ /*
exportLibraryBox = new JCheckBox("Enable advanced \"Library\" features" +
" (requires restart)");
exportLibraryBox.setEnabled(false);
@@ -267,6 +291,7 @@ public class PdePreferences extends JComponent {
exportLibraryBox.setBounds(left, top, d.width, d.height);
right = Math.max(right, left + d.width);
top += d.height + GUI_BETWEEN;
+ */
// [ ] Use external editor
@@ -297,14 +322,20 @@ public class PdePreferences extends JComponent {
pain.add(textarea);
*/
label = new JLabel("More preferences can be edited directly in the file");
- label.setForeground(Color.gray);
+
pain.add(label);
d = label.getPreferredSize();
+ label.setForeground(Color.gray);
label.setBounds(left, top, d.width, d.height);
top += d.height; // + GUI_SMALL;
label = new JLabel(preferencesFile.getAbsolutePath());
- label.setForeground(Color.gray);
+ label.addMouseListener(new MouseAdapter() {
+ public void mousePressed(MouseEvent e) {
+ PdeBase.openURL(preferencesFile.getAbsolutePath());
+ }
+ });
+ label.setForeground(new Color(51, 25, 153));
pain.add(label);
d = label.getPreferredSize();
label.setBounds(left, top, d.width, d.height);
@@ -371,6 +402,19 @@ public class PdePreferences extends JComponent {
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
frame.setLocation((screen.width - wide) / 2,
(screen.height - high) / 2);
+
+
+ // handle window closing commands for ctrl/cmd-W or hitting ESC.
+
+ addKeyListener(new KeyAdapter() {
+ public void keyPressed(KeyEvent e) {
+ KeyStroke wc = PdeEditor.WINDOW_CLOSE_KEYSTROKE;
+ if ((e.getKeyCode() == KeyEvent.VK_ESCAPE) ||
+ (KeyStroke.getKeyStrokeForEvent(e).equals(wc))) {
+ disposeFrame();
+ }
+ }
+ });
}
@@ -382,16 +426,21 @@ public class PdePreferences extends JComponent {
// .................................................................
+ /**
+ * Close the window after an OK or Cancel.
+ */
public void disposeFrame() {
- frame.hide();
- editor.applyPreferences();
- editor.show();
- //frame.dispose();
+ //frame.hide();
+ //editor.applyPreferences();
+ //editor.show();
+ frame.dispose();
}
- // change settings based on what was chosen in the prefs
-
+ /**
+ * Change internal settings based on what was chosen in the prefs,
+ * then send a message to the editor saying that it's time to do the same.
+ */
public void applyFrame() {
//editor.setExternalEditor(getBoolean("editor.external"));
// put each of the settings into the table
@@ -399,21 +448,33 @@ public class PdePreferences extends JComponent {
setBoolean("sketchbook.prompt", sketchPromptBox.isSelected());
setBoolean("sketchbook.auto_clean", sketchCleanBox.isSelected());
set("sketchbook.path", sketchbookLocationField.getText());
- setBoolean("export.library", exportLibraryBox.isSelected());
+ //setBoolean("export.library", exportLibraryBox.isSelected());
setBoolean("editor.external", externalEditorBox.isSelected());
+
+ String newSizeText = fontSizeField.getText();
+ try {
+ int newSize = Integer.parseInt(newSizeText.trim());
+ String pieces[] = PApplet.split(get("editor.font"), ',');
+ pieces[2] = String.valueOf(newSize);
+ set("editor.font", PApplet.join(pieces, ','));
+
+ } catch (Exception e) {
+ System.err.println("ignoring invalid font size " + newSizeText);
+ }
+ editor.applyPreferences();
}
public void showFrame(PdeEditor editor) {
// hide the editor window so it can't be messed with
this.editor = editor;
- editor.hide();
+ //editor.hide();
// set all settings entry boxes to their actual status
sketchPromptBox.setSelected(getBoolean("sketchbook.prompt"));
sketchCleanBox.setSelected(getBoolean("sketchbook.auto_clean"));
sketchbookLocationField.setText(get("sketchbook.path"));
- exportLibraryBox.setSelected(getBoolean("export.library"));
+ //exportLibraryBox.setSelected(getBoolean("export.library"));
externalEditorBox.setSelected(getBoolean("editor.external"));
frame.show();
@@ -423,7 +484,7 @@ public class PdePreferences extends JComponent {
// .................................................................
- public void load(InputStream input) throws IOException {
+ static public void load(InputStream input) throws IOException {
BufferedReader reader =
new BufferedReader(new InputStreamReader(input));
@@ -448,7 +509,7 @@ public class PdePreferences extends JComponent {
// .................................................................
- public void save() {
+ static public void save() {
try {
FileOutputStream output = new FileOutputStream(preferencesFile);
PrintWriter writer = new PrintWriter(new OutputStreamWriter(output));
diff --git a/app/PdePreprocessor.java b/app/PdePreprocessor.java
index 6d75bb863..ae09f7d54 100644
--- a/app/PdePreprocessor.java
+++ b/app/PdePreprocessor.java
@@ -181,11 +181,13 @@ public class PdePreprocessor {
imports.copyInto(extraImports);
// if using opengl, add it to the special imports
+ /*
if (PdePreferences.get("renderer").equals("opengl")) {
extraImports = new String[imports.size() + 1];
imports.copyInto(extraImports);
extraImports[extraImports.length - 1] = "processing.opengl.*";
}
+ */
/*
if (codeFolderPackages != null) {
@@ -348,19 +350,19 @@ public class PdePreprocessor {
}
}
- boolean opengl = PdePreferences.get("renderer").equals("opengl");
- if (opengl) {
- out.println("import processing.opengl.*; ");
- }
+ //boolean opengl = PdePreferences.get("renderer").equals("opengl");
+ //if (opengl) {
+ //out.println("import processing.opengl.*; ");
+ //}
if (programType < JAVA) {
// open the class definition
out.print("public class " + className + " extends ");
- if (opengl) {
- out.print("PAppletGL");
- } else {
- out.print("PApplet");
- }
+ //if (opengl) {
+ //out.print("PAppletGL");
+ //} else {
+ out.print("PApplet");
+ //}
out.print(" {");
if (programType == STATIC) {
diff --git a/app/PdeRuntime.java b/app/PdeRuntime.java
index 094456dde..4f5cb8d7b 100644
--- a/app/PdeRuntime.java
+++ b/app/PdeRuntime.java
@@ -1,10 +1,10 @@
/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
- PdeRuntime - runs compiled java applet
+ PdeRuntime - runs a compiled java applet
Part of the Processing project - http://processing.org
- Except where noted, code is written by Ben Fry and is
+ Copyright (c) 2004-05 Ben Fry and Casey Reas
Copyright (c) 2001-04 Massachusetts Institute of Technology
This program is free software; you can redistribute it and/or modify
@@ -52,10 +52,6 @@ public class PdeRuntime implements PdeMessageConsumer {
OutputStream processOutput;
PdeMessageSiphon processError;
- //boolean externalRuntime;
- //String libraryPath;
- //String classPath;
-
public PdeRuntime(PdeSketch sketch, PdeEditor editor) {
this.sketch = sketch;
@@ -64,245 +60,18 @@ public class PdeRuntime implements PdeMessageConsumer {
public void start(Point windowLocation) throws PdeException {
-
+ //System.out.println(" externalRuntime is " + sketch.externalRuntime);
this.leechErr = new PrintStream(new PdeMessageStream(this));
- Point parentLoc = editor.getLocation();
- Insets parentInsets = editor.getInsets();
-
- int x1 = parentLoc.x - 20;
- int y1 = parentLoc.y;
-
- // try to figure out the size of the applet from the code
-
- int initialWidth = PApplet.DEFAULT_WIDTH;
- int initialHeight = PApplet.DEFAULT_HEIGHT;
-
try {
- PatternMatcher matcher = new Perl5Matcher();
- PatternCompiler compiler = new Perl5Compiler();
+ if (editor.presenting) {
+ startPresenting();
- // this matches against any uses of the size() function,
- // whether they contain numbers of variables or whatever.
- // this way, no warning is shown if size() isn't actually
- // used in the applet, which is the case especially for
- // beginners that are cutting/pasting from the reference.
- String sizing =
- "[\\s\\;]size\\s*\\(\\s*(\\S+)\\s*,\\s*(\\S+)\\s*\\);";
- Pattern pattern = compiler.compile(sizing);
+ } else if (sketch.externalRuntime) {
+ startExternalRuntime(windowLocation);
- // adds a space at the beginning, in case size() is the very
- // first thing in the program (very common), since the regexp
- // needs to check for things in front of it.
- PatternMatcherInput input =
- new PatternMatcherInput(" " + sketch.code[0].program);
- if (matcher.contains(input, pattern)) {
- MatchResult result = matcher.getMatch();
- try {
- initialWidth = Integer.parseInt(result.group(1).toString());
- initialHeight = Integer.parseInt(result.group(2).toString());
-
- } catch (NumberFormatException e) {
- /*
- // found a reference to size, but it didn't
- // seem to contain numbers
- final String message =
- "The size of this applet could not automatically be\n" +
- "determined from your code. You'll have to edit the\n" +
- "HTML file to set the size of the applet.";
-
- PdeBase.showWarning("Could not find applet size", message, null);
- */
- }
- } // else no size() command found
- } catch (Exception e) {
- e.printStackTrace(); // later fail silently
- }
-
- try {
- if (sketch.externalRuntime) {
- // if there was a saved location (this guy has been run more than
- // once) then windowLocation will be set to the last position of
- // the sketch window. this will be passed to the PApplet runner
- // using something like --external=e30,20 where the e stands for
- // exact. otherwise --external=x,y for just the regular positioning.
- /*
- String location = (windowLocation != null) ?
- (PApplet.EXTERNAL_EXACT_LOCATION +
- windowLocation.x + "," + windowLocation.y) :
- (x1 + "," + y1);
- */
- String location =
- (windowLocation != null) ?
- (PApplet.EXT_EXACT_LOCATION +
- windowLocation.x + "," + windowLocation.y) :
- (PApplet.EXT_LOCATION + x1 + "," + y1);
-
- //System.out.println("library path is " + sketch.libraryPath);
- String command[] = new String[] {
- //"cmd", "/c", "start",
-
- "java",
- "-Djava.library.path=" +
- // sketch.libraryPath might be ""
- // librariesClassPath will always have sep char prepended
- sketch.libraryPath +
- File.pathSeparator + System.getProperty("java.library.path"),
- "-cp",
- sketch.classPath + PdeSketchbook.librariesClassPath,
- "processing.core.PApplet",
- location,
- PApplet.EXT_SIZE + initialWidth + "," + initialHeight,
- PApplet.EXT_SKETCH_FOLDER + sketch.folder.getAbsolutePath(),
- sketch.mainClassName
- };
- //PApplet.printarr(command);
- //PApplet.println(PApplet.join(command, " "));
-
- process = Runtime.getRuntime().exec(command);
- processInput = new SystemOutSiphon(process.getInputStream());
- processError = new PdeMessageSiphon(process.getErrorStream(), this);
- processOutput = process.getOutputStream();
-
- } else { // !externalRuntime
- PdeClassLoader loader = new PdeClassLoader();
- Class c = loader.loadClass(sketch.mainClassName);
- applet = (PApplet) c.newInstance();
-
- // replaces setRuntime with PApplet having leechErr [fry]
- applet.leechErr = leechErr;
- applet.folder = sketch.folder.getAbsolutePath();
-
- // has to be before init
- //applet.serialProperties(PdePreferences.properties);
- applet.init();
- if (applet.exception != null) {
- /*
- TODO: fix me
- if (applet.exception instanceof PortInUseException) {
- throw new PdeException("Another program is already " +
- "using the serial port.");
- } else {
- */
- throw new PdeException(applet.exception.getMessage());
- }
- applet.start();
-
- if (editor.presenting) {
- //window = new Window(new Frame());
- // toxi_030903: attach applet window to editor's presentation window
- window = new Window(editor.presentationWindow);
- // toxi_030903: moved keyListener to PdeEditor's presentationWindow
-
- } else {
- //window = new Frame(sketch.name); // use ugly windows
- window = new Frame(sketch.name); // use ugly windows
- ((Frame)window).setResizable(false);
- if (editor.icon != null) {
- ((Frame)window).setIconImage(editor.icon);
- }
- window.pack(); // to get a peer, size set later, need for insets
-
- window.addWindowListener(new WindowAdapter() {
- public void windowClosing(WindowEvent e) {
- stop();
- editor.doClose();
- }
- });
-
- // toxi_030903: only attach keyListener if not in presentation mode
- // else events are coming directly from editor.presentationWindow
- applet.addKeyListener(new KeyAdapter() {
- public void keyPressed(KeyEvent e) {
- //System.out.println("applet got " + e);
- if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
- stop();
- editor.doClose();
- }
- }
- });
- y1 += parentInsets.top;
- }
- window.add(applet);
-
- Dimension screen =
- Toolkit.getDefaultToolkit().getScreenSize();
-
- window.setLayout(null);
- if (editor.presenting) {
- /*
- window.setBounds((screen.width - applet.width) / 2,
- (screen.height - applet.height) / 2,
- applet.width, applet.height);
- applet.setBounds(0, 0, applet.width, applet.height);
- */
- window.setBounds((screen.width - initialWidth) / 2,
- (screen.height - initialHeight) / 2,
- initialWidth, initialHeight);
- applet.setBounds(0, 0, initialWidth, initialHeight);
-
- } else {
- Insets insets = window.getInsets();
- //System.out.println(insets);
-
- if ((applet.width != 0) &&
- (applet.height != 0) &&
- (applet.width != PApplet.DEFAULT_WIDTH) &&
- (applet.height != PApplet.DEFAULT_HEIGHT)) {
- initialWidth = applet.width;
- initialHeight = applet.height;
- }
-
- int minW = PdePreferences.getInteger("run.window.width.minimum");
- int minH = PdePreferences.getInteger("run.window.height.minimum");
- int windowW =
- Math.max(initialWidth, minW) + insets.left + insets.right;
- //Math.max(applet.width, minW) + insets.left + insets.right;
- int windowH =
- Math.max(initialHeight, minH) + insets.top + insets.bottom;
- //Math.max(applet.height, minH) + insets.top + insets.bottom;
-
- if (x1 - windowW > 10) { // if it fits to the left of the window
- window.setBounds(x1 - windowW, y1, windowW, windowH);
- //windowX = x1 - ww;
- //windowY = y1;
-
- } else { // if it fits inside the editor window
- x1 = parentLoc.x + PdePreferences.GRID_SIZE * 2; // 66
- y1 = parentLoc.y + PdePreferences.GRID_SIZE * 2; // 66
-
- if ((x1 + windowW > screen.width - PdePreferences.GRID_SIZE) ||
- (y1 + windowH > screen.height - PdePreferences.GRID_SIZE)) {
- // otherwise center on screen
- x1 = (screen.width - windowW) / 2;
- y1 = (screen.height - windowH) / 2;
- }
- window.setBounds(x1, y1, windowW, windowH); //ww, wh);
- }
-
- Color windowBgColor = PdePreferences.getColor("run.window.bgcolor");
- window.setBackground(windowBgColor);
-
- /*
- applet.setBounds((windowW - applet.width)/2,
- insets.top + ((windowH -
- insets.top - insets.bottom) -
- applet.height)/2,
- windowW, windowH);
- */
- applet.setBounds((windowW - initialWidth)/2,
- insets.top + ((windowH -
- insets.top - insets.bottom) -
- initialHeight)/2,
- windowW, windowH);
- }
-
- applet.setVisible(true); // no effect
- if (windowLocation != null) {
- window.setLocation(windowLocation);
- }
- window.show();
- applet.requestFocus(); // necessary for key events
+ } else {
+ startInternal(windowLocation);
}
} catch (Exception e) {
@@ -319,6 +88,173 @@ public class PdeRuntime implements PdeMessageConsumer {
}
+ public void startPresenting() throws Exception {
+ String command[] = new String[] {
+ "java",
+ "-Djava.library.path=" +
+ sketch.libraryPath +
+ File.pathSeparator + System.getProperty("java.library.path"),
+ "-cp",
+ sketch.classPath + PdeSketchbook.librariesClassPath,
+ "processing.core.PApplet",
+ PApplet.ARGS_EXTERNAL,
+ PApplet.ARGS_PRESENT,
+ PApplet.ARGS_PRESENT_BGCOLOR + "=" +
+ PdePreferences.get("run.present.bgcolor"),
+ PApplet.ARGS_DISPLAY + "=" +
+ PdePreferences.get("run.display"),
+ PApplet.ARGS_SKETCH_FOLDER + "=" +
+ sketch.folder.getAbsolutePath(),
+ sketch.mainClassName
+ };
+
+ process = Runtime.getRuntime().exec(command);
+ processInput = new SystemOutSiphon(process.getInputStream());
+ processError = new PdeMessageSiphon(process.getErrorStream(), this);
+ processOutput = process.getOutputStream();
+ }
+
+
+ public void startExternalRuntime(Point windowLocation) throws Exception {
+ // if there was a saved location (this guy has been run more than
+ // once) then windowLocation will be set to the last position of
+ // the sketch window. this will be passed to the PApplet runner
+ // using something like --external=e30,20 where the e stands for
+ // exact. otherwise --external=x,y for just the regular positioning.
+ Point editorLocation = editor.getLocation();
+ String location =
+ (windowLocation != null) ?
+ (PApplet.ARGS_LOCATION + "=" +
+ windowLocation.x + "," + windowLocation.y) :
+ (PApplet.ARGS_EDITOR_LOCATION + "=" +
+ editorLocation.x + "," + editorLocation.y);
+
+ //System.out.println("library path is " + sketch.libraryPath);
+ String command[] = new String[] {
+ // this made the code folder bug go away, but killed stdio
+ //"cmd", "/c", "start",
+ "java",
+ "-Djava.library.path=" +
+ // sketch.libraryPath might be ""
+ // librariesClassPath will always have sep char prepended
+ sketch.libraryPath +
+ File.pathSeparator + System.getProperty("java.library.path"),
+ "-cp",
+ sketch.classPath + PdeSketchbook.librariesClassPath,
+ "processing.core.PApplet",
+ location,
+ PApplet.ARGS_EXTERNAL,
+ PApplet.ARGS_DISPLAY + "=" + PdePreferences.get("run.display"),
+ PApplet.ARGS_SKETCH_FOLDER + "=" + sketch.folder.getAbsolutePath(),
+ sketch.mainClassName
+ };
+ //PApplet.printarr(command);
+ //PApplet.println(PApplet.join(command, " "));
+
+ process = Runtime.getRuntime().exec(command);
+ processInput = new SystemOutSiphon(process.getInputStream());
+ processError = new PdeMessageSiphon(process.getErrorStream(), this);
+ processOutput = process.getOutputStream();
+ }
+
+
+ public void startInternal(Point windowLocation) throws Exception {
+ Point editorLocation = editor.getLocation();
+ //Insets editorInsets = editor.getInsets();
+
+ int windowX = editorLocation.x;
+ int windowY = editorLocation.y + editor.getInsets().top;
+
+ PdeClassLoader loader = new PdeClassLoader();
+ Class c = loader.loadClass(sketch.mainClassName);
+ applet = (PApplet) c.newInstance();
+
+ applet.leechErr = leechErr;
+ applet.folder = sketch.folder.getAbsolutePath();
+
+ applet.init();
+ //applet.start();
+
+ while ((applet.width == 0) && !applet.finished) {
+ try {
+ if (applet.exception != null) {
+ throw new PdeException(applet.exception.getMessage());
+ }
+ Thread.sleep(5);
+ } catch (InterruptedException e) { }
+ }
+
+ window = new Frame(sketch.name); // use ugly window
+ ((Frame)window).setResizable(false);
+ if (editor.icon != null) {
+ ((Frame)window).setIconImage(editor.icon);
+ }
+ window.pack(); // to get a peer, size set later, need for insets
+
+ window.addWindowListener(new WindowAdapter() {
+ public void windowClosing(WindowEvent e) {
+ stop();
+ editor.doClose();
+ }
+ });
+
+ applet.addKeyListener(new KeyAdapter() {
+ public void keyPressed(KeyEvent e) {
+ if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
+ stop();
+ editor.doClose();
+ }
+ }
+ });
+
+ window.add(applet);
+
+ Dimension screen =
+ Toolkit.getDefaultToolkit().getScreenSize();
+
+ window.setLayout(null);
+ Insets insets = window.getInsets();
+
+ int minW = PdePreferences.getInteger("run.window.width.minimum");
+ int minH = PdePreferences.getInteger("run.window.height.minimum");
+ int windowW =
+ Math.max(applet.width, minW) + insets.left + insets.right;
+ int windowH =
+ Math.max(applet.height, minH) + insets.top + insets.bottom;
+
+ if (windowX - windowW > 10) { // if it fits to the left of the window
+ window.setBounds(windowX - windowW, windowY, windowW, windowH);
+
+ } else { // if it fits inside the editor window
+ windowX = editorLocation.x + PdePreferences.GRID_SIZE * 2; // 66
+ windowY = editorLocation.y + PdePreferences.GRID_SIZE * 2; // 66
+
+ if ((windowX + windowW > screen.width - PdePreferences.GRID_SIZE) ||
+ (windowY + windowH > screen.height - PdePreferences.GRID_SIZE)) {
+ // otherwise center on screen
+ windowX = (screen.width - windowW) / 2;
+ windowY = (screen.height - windowH) / 2;
+ }
+ window.setBounds(windowX, windowY, windowW, windowH); //ww, wh);
+ }
+
+ Color windowBgColor = PdePreferences.getColor("run.window.bgcolor");
+ window.setBackground(windowBgColor);
+
+ int usableH = windowH - insets.top - insets.bottom;
+ applet.setBounds((windowW - applet.width)/2,
+ insets.top + (usableH - applet.height) / 2,
+ windowW, windowH);
+
+ applet.setVisible(true); // no effect
+ if (windowLocation != null) {
+ window.setLocation(windowLocation);
+ }
+ window.show();
+ applet.requestFocus(); // necessary for key events
+ }
+
+
public void stop() {
// check for null in case stop is called during compilation
if (applet != null) {
diff --git a/app/PdeSketch.java b/app/PdeSketch.java
index 750a52cfe..acc8c5c28 100644
--- a/app/PdeSketch.java
+++ b/app/PdeSketch.java
@@ -1153,9 +1153,9 @@ public class PdeSketch {
}
// if running in opengl mode, this is gonna be external
- if (PdePreferences.get("renderer").equals("opengl")) {
- externalRuntime = true;
- }
+ //if (PdePreferences.get("renderer").equals("opengl")) {
+ //externalRuntime = true;
+ //}
// 2. run preproc on that code using the sugg class name
// to create a single .java file and write to buildpath
diff --git a/app/PdeSketchbook.java b/app/PdeSketchbook.java
index 2e4313a43..838c208ed 100644
--- a/app/PdeSketchbook.java
+++ b/app/PdeSketchbook.java
@@ -199,8 +199,7 @@ public class PdeSketchbook {
// jdk13 on osx, or jdk11
// though apparently still available for 1.4
- if ((PdeBase.platform == PdeBase.MACOS9) ||
- (PdeBase.platform == PdeBase.MACOSX)) {
+ if (PdeBase.isMacOS()) {
MRJFileUtils.setFileTypeAndCreator(newbieFile,
MRJOSType.kTypeTEXT,
new MRJOSType("Pde1"));
diff --git a/build/linux/dist.sh b/build/linux/dist.sh
index 3dcf755d5..f17a20f21 100755
--- a/build/linux/dist.sh
+++ b/build/linux/dist.sh
@@ -15,9 +15,11 @@ cp -r ../shared processing
# add the libraries folder with source
cp -r ../../lib processing/libraries
-
+cp -r ../../net ../../lib processing/libraries/
+cp -r ../../opengl ../../lib processing/libraries/
+cp -r ../../serial ../../lib processing/libraries/
# doesn't work on linux, don't include it and confuse people
-rm -rf processing/libraries/video
+#cp -r ../../video ../../lib processing/libraries/
# new style examples thing ala reas
cd processing
diff --git a/build/linux/make.sh b/build/linux/make.sh
index 1a475dc5f..562cabe87 100755
--- a/build/linux/make.sh
+++ b/build/linux/make.sh
@@ -92,7 +92,7 @@ cd app
CLASSPATH="../build/linux/work/lib/core.jar:../build/linux/work/lib/mrj.jar:../build/linux/work/lib/antlr.jar:../build/linux/work/lib/oro.jar:../build/linux/work/lib/registry.jar:../build/linux/work/java/lib/rt.jar"
-../build/linux/work/jikes +D -classpath $CLASSPATH -d ../build/linux/work/classes *.java jeditsyntax/*.java preprocessor/*.java tools/*.java
+../build/linux/work/jikes -target 1.3 +D -classpath $CLASSPATH -d ../build/linux/work/classes *.java jeditsyntax/*.java preprocessor/*.java tools/*.java
cd ../build/linux/work/classes
rm -f ../lib/pde.jar
@@ -104,48 +104,98 @@ cd ../../../..
### -- BUILD LIBRARIES ------------------------------------------------
+echo build libs for linux is incomplete... finish it
+exit
+
+
cd build/linux
+PLATFORM=linux
-CLASSPATH="../../build/linux/work/lib/core.jar:../../build/linux/work/java/lib/rt.jar"
+#CLASSPATH="../../build/linux/work/lib/core.jar:../../build/linux/work/java/lib/rt.jar"
+CLASSPATH=../build/$PLATFORM/work/lib/core.jar:$CLASSPATH
+JIKES=../build/$PLATFORM/work/jikes
+CORE=../build/$PLATFORM/work/lib/core.jar
+LIBRARIES=../build/$PLATFORM/work/libraries
+
+# move to processing/build
+cd ..
# SERIAL LIBRARY
-echo Build serial library...
-cd ../../lib/serial
-../../build/linux/work/jikes -target 1.1 +D -classpath "code/RXTXcomm.jar:$CLASSPATH" -d . *.java
+echo Building serial library...
+cd ../serial
+$JIKES -target 1.1 +D -classpath "code/RXTXcomm.jar:$CORE:$CLASSPATH" -d . *.java
rm -f library/serial.jar
zip -r0q library/serial.jar processing
rm -rf processing
-mkdir -p ../../build/linux/work/libraries/serial/library/
-cp library/serial.jar ../../build/linux/work/libraries/serial/library/
+mkdir -p $LIBRARIES/serial/library/
+cp library/serial.jar $LIBRARIES/serial/library/
# NET LIBRARY
-echo Build net library...
-cd ../../lib/net
-../../build/linux/work/jikes -target 1.1 +D -d . *.java
+echo Building net library...
+cd ../net
+$JIKES -target 1.1 +D -d . *.java
rm -f library/net.jar
zip -r0q library/net.jar processing
rm -rf processing
-mkdir -p ../../build/linux/work/libraries/net/library/
-cp library/net.jar ../../build/linux/work/libraries/net/library/
+mkdir -p $LIBRARIES/net/library/
+cp library/net.jar $LIBRARIES/net/library/
+
+
+# VIDEO LIBRARY
+echo Building video library...
+QTJAVA=/System/Library/Java/Extensions/QTJava.zip
+if test -f "${QTJAVA}"
+then
+ echo "Found QuickTime for Java at $QTJAVA"
+else
+ echo "QuickTime for Java must be installed before building."
+ exit 1;
+fi
+cd ../video
+$JIKES -target 1.1 +D -classpath "$QTJAVA:$CLASSPATH" -d . *.java
+rm -f library/video.jar
+zip -r0q library/video.jar processing
+rm -rf processing
+mkdir -p $LIBRARIES/video/library/
+cp library/video.jar $LIBRARIES/video/library/
+
+
+# OPENGL LIBRARY
+echo Building OpenGL library...
+cd ../opengl
+$JIKES -target 1.1 +D -classpath "library/jogl.jar:$CLASSPATH" -d . *.java
+rm -f library/opengl.jar
+zip -r0q library/opengl.jar processing
+rm -rf processing
+mkdir -p $LIBRARIES/opengl/library/
+cp library/opengl.jar $LIBRARIES/opengl/library/
+
+
+CLASSPATH=../$CLASSPATH
+JIKES=../../build/$PLATFORM/work/jikes
+CORE=../../build/$PLATFORM/work/lib/core.jar
+LIBRARIES=../../build/$PLATFORM/work/libraries
# PARTICLES LIBRARY
echo Build particles library...
-cd ../../lib/particles
-../../build/linux/work/jikes -target 1.1 +D -d . *.java
+cd ../lib/particles
+$JIKES -target 1.1 +D -d . *.java
rm -f library/particles.jar
zip -r0q library/particles.jar simong
rm -rf simong
-mkdir -p ../../build/linux/work/libraries/particles/library/
-cp library/particles.jar ../../build/linux/work/libraries/particles/library/
+mkdir -p $LIBRARIES/particles/library/
+cp library/particles.jar $LIBRARIES/particles/library/
+pwd
-cd ../../build/linux
### -- BUILD STUB -----------------------------------------------
+cd ../../build/linux
+
install -m 755 dist/processing work/processing
diff --git a/build/macosx/dist.sh b/build/macosx/dist.sh
index adcc52c91..cd52192da 100755
--- a/build/macosx/dist.sh
+++ b/build/macosx/dist.sh
@@ -38,6 +38,10 @@ cp -r ../shared processing
# add the libraries folder with source
cp -r ../../lib processing/libraries
+cp -r ../../net ../../lib processing/libraries/
+cp -r ../../opengl ../../lib processing/libraries/
+cp -r ../../serial ../../lib processing/libraries/
+cp -r ../../video ../../lib processing/libraries/
# new style examples thing ala reas
cd processing
diff --git a/build/macosx/dist/Processing.app/Contents/Info.plist b/build/macosx/dist/Processing.app/Contents/Info.plist
index 9bcd74e6e..83eccd663 100755
--- a/build/macosx/dist/Processing.app/Contents/Info.plist
+++ b/build/macosx/dist/Processing.app/Contents/Info.plist
@@ -53,7 +53,7 @@
+ * Access this via screen.width and screen.height. To make an applet + * run at full screen, use size(screen.width, screen.height). + *
+ * This won't update if you change the resolution of your screen + * once the the applet is running. + */ + static public Dimension screen = + Toolkit.getDefaultToolkit().getScreenSize(); + + //protected PMethods recorder; + public PGraphics recorder; + + /** + * Command line options passed in from main() + *
+ * This does not include the arguments passed in to PApplet itself. + */ public String args[]; /** Path to sketch folder */ - public String folder; // = System.getProperty("user.dir"); + public String folder; /** When debugging headaches */ static final boolean THREAD_DEBUG = false; + static public final int DEFAULT_WIDTH = 100; + static public final int DEFAULT_HEIGHT = 100; + + //protected int INITIAL_WIDTH = DEFAULT_WIDTH; + //protected int INITIAL_HEIGHT = DEFAULT_HEIGHT; + + /** + * Pixel buffer from this applet's PGraphics. + *
+ * When used with OpenGL or Java2D, this value will + * be null until loadPixels() has been called. + */ public int pixels[]; - public int mouseX, mouseY; + /** width of this applet's associated PGraphics */ + public int width; - public int pmouseX, pmouseY; + /** height of this applet's associated PGraphics */ + public int height; + + /** current x position of the mouse */ + public int mouseX; + + /** current y position of the mouse */ + public int mouseY; + + /** previous x position of the mouse */ + public int pmouseX; + + /** previous y position of the mouse */ + public int pmouseY; /** * previous mouseX/Y for the draw loop, separated out because this is @@ -99,19 +186,28 @@ public class PApplet extends Applet /** * Last key pressed. *
- * If it's a coded key (arrows or ctrl/shift/alt, - * this will be set to 0xffff or 65535). + * If it's a coded key, i.e. UP/DOWN/CTRL/SHIFT/ALT, + * this will be set to CODED (0xffff or 65535). */ public char key; /** - * If the key is a coded key such as UP/DOWN/CTRL/SHIFT/ALT, - * the 'key' comes through as 0xffff (65535) and keyCode will - * contain the proper value. + * When "key" is set to CODED, this will contain a Java key code. + *
+ * For the arrow keys, keyCode will be one of UP, DOWN, LEFT and RIGHT. + * Also available are ALT, CONTROL and SHIFT. A full set of constants + * can be obtained from java.awt.event.KeyEvent, from the VK_XXXX variables. */ public int keyCode; + /** + * true if the mouse is currently pressed. + */ public boolean keyPressed; + + /** + * the last KeyEvent object passed into a mouse function. + */ public KeyEvent keyEvent; /** @@ -127,93 +223,128 @@ public class PApplet extends Applet */ public boolean online = false; + /** + * Time in milliseconds when the applet was started. + *
+ * Used by the millis() function. + */ long millisOffset; - // getting the frame rate - protected float fps = 10; - protected long fpsLastMillis = 0; + /** + * The current value of frames per second. + *
+ * The initial value will be 10 fps, and will be updated with each + * frame thereafter. The value is not instantaneous (since that + * wouldn't be very useful since it would jump around so much), + * but is instead averaged (integrated) over several frames. + * As such, this value won't be valid until after 5-10 frames. + */ + public float framerate = 10; + protected long framerateLastMillis = 0; // setting the frame rate - protected long fpsLastDelayTime = 0; - protected float fpsTarget = 0; + protected long framerateLastDelayTime = 0; + protected float framerateTarget = 0; - //boolean drawMethod; - //boolean loopMethod; protected boolean looping; + + /** flag set to true when a redraw is asked for by the user */ protected boolean redraw; - // true if inside the loop method - //boolean insideLoop; - - // used for mouse tracking so that pmouseX doesn't get - // updated too many times while still inside the loop - // instead, it's updated only before/after the loop() - //int qmouseX, qmouseY; - - // queue for whether to call the simple mouseDragged or - // mouseMoved functions. these are called after beginFrame - // but before loop() is called itself, to avoid problems - // in synchronization. - //boolean qmouseDragged; - //boolean qmouseMoved; - - //boolean firstFrame; - - // current frame number (could this be used to replace firstFrame?) + /** + * How many frames have been displayed since the applet started. + *
+ * This value is read-only do not attempt to set it, + * otherwise bad things will happen. + *
+ * Inside setup(), frameCount is 0. + * For the first iteration of draw(), frameCount will equal 1. + */ public int frameCount; - // true if the feller has spun down + /** + * true if this applet has had it. + */ public boolean finished; - //boolean drawn; Thread thread; - public Exception exception; // the last exception thrown - - static public final int DEFAULT_WIDTH = 100; - static public final int DEFAULT_HEIGHT = 100; - - protected int INITIAL_WIDTH = DEFAULT_WIDTH; - protected int INITIAL_HEIGHT = DEFAULT_HEIGHT; - - public int width, height; + /** + * Set to the an exception that occurs inside run() and is not + * caught.
Used by PdeRuntime to determine what happened and + * report back to the user. + */ + public Exception exception; protected RegisteredMethods sizeMethods; protected RegisteredMethods preMethods, drawMethods, postMethods; protected RegisteredMethods mouseEventMethods, keyEventMethods; protected RegisteredMethods disposeMethods; - //protected int libraryCount; - //protected PLibrary libraries[]; - //protected boolean libraryCalls[][]; - //int setupCount = 0; - // this text isn't seen unless PApplet is used on its // own and someone takes advantage of leechErr.. not likely static public final String LEECH_WAKEUP = "Error while running applet."; public PrintStream leechErr; - // message to send if attached as an external vm - //static public final String EXTERNAL_FLAG = "--external="; - //static public final char EXTERNAL_EXACT_LOCATION = 'e'; - static public final String EXT_LOCATION = "--location="; - static public final String EXT_SIZE = "--size="; - static public final String EXT_EXACT_LOCATION = "--exact-location="; - static public final String EXT_SKETCH_FOLDER = "--sketch-folder="; + // messages to send if attached as an external vm + /** + * Position of the upper-lefthand corner of the editor window + * that launched this applet. + */ + static public final String ARGS_EDITOR_LOCATION = "--editor-location"; + + /** + * Location for where to position the applet window on screen. + *
+ * This is used by the editor to when saving the previous applet + * location, or could be used by other classes to launch at a + * specific position on-screen. + */ + static public final String ARGS_EXTERNAL = "--external"; + + static public final String ARGS_LOCATION = "--location"; + + static public final String ARGS_DISPLAY = "--display"; + + static public final String ARGS_PRESENT = "--present"; + + static public final String ARGS_PRESENT_BGCOLOR = "--present-color"; + + static public final String ARGS_PRESENT_STOP_COLOR = "--present-stop-color"; + + /** + * Allows the user or PdeEditor to set a specific sketch folder path. + *
+ * Used by PdeEditor to pass in the location where saveFrame() + * and all that stuff should write things. + */ + static public final String ARGS_SKETCH_FOLDER = "--sketch-folder"; + + /** + * Message from parent editor (when run as external) to quit. + */ static public final char EXTERNAL_STOP = 's'; - static public final String EXTERNAL_QUIT = "__QUIT__"; - static public final String EXTERNAL_MOVE = "__MOVE__"; - //boolean externalRuntime; - //static boolean setupComplete = false; + /** + * When run externally to a PdeEditor, + * this is sent by the applet when it quits. + */ + static public final String EXTERNAL_QUIT = "__QUIT__"; + + /** + * When run externally to a PdeEditor, this is sent by the applet + * whenever the window is moved. + *
+ * This is used so that the editor can re-open the sketch window + * in the same position as the user last left it. + */ + static public final String EXTERNAL_MOVE = "__MOVE__"; + public void init() { - //checkParams(); - // can/may be resized later - //g = new PGraphics(DEFAULT_WIDTH, DEFAULT_HEIGHT); - initGraphics(); + //initGraphics(); // send tab keys through to the PApplet try { @@ -244,6 +375,12 @@ public class PApplet extends Applet keyEventMethods = new RegisteredMethods(); disposeMethods = new RegisteredMethods(); + // create a dummy graphics context + size(DEFAULT_WIDTH, DEFAULT_HEIGHT); + //size(INITIAL_WIDTH, INITIAL_HEIGHT); + width = 0; // use this to flag whether the width/height are valid + height = 0; + try { getAppletContext(); online = true; @@ -255,6 +392,7 @@ public class PApplet extends Applet } + /* // override for subclasses (i.e. opengl) // so that init() doesn't have to be replicated public void initGraphics() { @@ -303,6 +441,7 @@ public class PApplet extends Applet // fine since it's post-beginFrame. g.defaults(); } + */ /** @@ -500,8 +639,8 @@ public class PApplet extends Applet looping = false; // reset framerate delay times - fpsLastDelayTime = 0; - fpsLastMillis = 0; + framerateLastDelayTime = 0; + framerateLastMillis = 0; if (thread != null) { thread.interrupt(); // wake from sleep @@ -513,7 +652,124 @@ public class PApplet extends Applet ////////////////////////////////////////////////////////////// + /** + * Starts up and creates a two-dimensional drawing surface. + *
+ * If using Java 1.3 or later, this will default to using + * PGraphics2, the Java2D-based renderer. If using Java 1.1, + * or if PGraphics2 is not available, then PGraphics will be used. + * To set your own renderer, use the other version of the size() + * method that takes a renderer as its last parameter. + *
+ * If called once a renderer has already been set, this will + * use the previous renderer and simply resize it. + */ public void size(int iwidth, int iheight) { + if (g != null) { + // just resize the current renderer + size(iwidth, iheight, g.getClass().getName()); + + } else { + if (PApplet.JDK_VERSION >= 1.3) { + try { + Class c = Class.forName(JAVA2D); + size(iwidth, iheight, JAVA2D); + return; + + } catch (ClassNotFoundException e) { } + } + size(iwidth, iheight, P2D); // fall-through case + } + } + + + /** + * Creates a new PGraphics object and sets it to the specified size. + *
+ * Note that you cannot change the renderer once outside of setup(). + * You can call size() to give it a new size, but you need to always + * ask for the same renderer, otherwise you're gonna run into trouble. + */ + public void size(int iwidth, int iheight, String renderer) { + String currentRenderer = (g == null) ? null : g.getClass().getName(); + + if (currentRenderer != null) { + if (currentRenderer.equals(renderer)) { + if ((iwidth == g.width) && (iheight == g.height)) { + // all set, the renderer was queued up last time + // before throwing the exception + //System.out.println("ignoring additional size()"); + return; + } + } else { + if (frameCount > 0) { + throw new RuntimeException("size() cannot be called to change " + + "the renderer outside of setup()"); + } + } + } + + try { + //if (renderer.equals(OPENGL)) { + //g = new processing.opengl.PGraphicsGL(iwidth, iheight, this); + //} else { + + Class rendererClass = Class.forName(renderer); + Class constructorParams[] = + new Class[] { Integer.TYPE, + Integer.TYPE, + PApplet.class }; + Constructor constructor = + rendererClass.getConstructor(constructorParams); + Object constructorValues[] = + new Object[] { new Integer(iwidth), + new Integer(iheight), + this }; + // create the actual PGraphics object for rendering + //System.out.println("creating new PGraphics " + constructor); + g = (PGraphics) + constructor.newInstance(constructorValues); + + //System.out.println("setting size to + this.width = iwidth; + this.height = iheight; + + //width = g.width; + //height = g.height; + //pixels = g.pixels; // this may be null + + // make the applet itself larger + setSize(width, height); + + // probably needs to mess with the parent frame here? + // TODO wait for a "legitimate size" flag to be set + // (meaning that setup has finished properly) + // at which time the parent frame will do its thing. + + } catch (InvocationTargetException ite) { + String msg = ite.getTargetException().getMessage(); + if (msg.indexOf("no jogl in java.library.path") != -1) { + throw new RuntimeException("Before using OpenGL, you must " + + "first select Import Library > " + + "opengl from the Sketch menu."); + //System.out.println("ite found: " + ite.getTargetException().getMessage()); + } else { + ite.getTargetException().printStackTrace(); + } + + } catch (Exception e) { + e.printStackTrace(); + die("Could not start because of a problem with size()", e); + } + + // throw an exception so that setup() is called again + // but with a properly sized render + if ((currentRenderer != null) && + !currentRenderer.equals(renderer)) { + throw new RuntimeException(NEW_RENDERER); + } + + /* if (g == null) return; g.resize(iwidth, iheight); @@ -521,10 +777,6 @@ public class PApplet extends Applet this.width = g.width; this.height = g.height; - Object methodArgs[] = - new Object[] { new Integer(width), new Integer(height) }; - sizeMethods.handle(methodArgs); - if (frame != null) { Insets insets = frame.getInsets(); @@ -542,6 +794,11 @@ public class PApplet extends Applet //System.out.println("frame was null"); //setBounds(0, 0, width, height); } + */ + + Object methodArgs[] = + new Object[] { new Integer(width), new Integer(height) }; + sizeMethods.handle(methodArgs); } @@ -564,6 +821,7 @@ public class PApplet extends Applet if (frameCount == 0) { // paint() may be called more than once before things // are finally painted to the screen and the thread gets going + //System.out.println("not painting"); /* if (thread == null) { initGraphics(); @@ -597,7 +855,7 @@ public class PApplet extends Applet //g.mis.newPixels(pixels, g.cm, 0, width); // must call this // make sure the screen is visible and usable - if (g != null) { + if ((g != null) && (g.image != null)) { screen.drawImage(g.image, 0, 0, null); } //if (THREAD_DEBUG) println("notifying all"); @@ -625,16 +883,86 @@ public class PApplet extends Applet while ((Thread.currentThread() == thread) && !finished) { //while ((thread != null) && !finished) { - //while (!finished) { + //while (!finished) { //updated = false; + // render a single frame + g.requestDisplay(this); + + // moving this to update() (for 0069+) for linux sync problems + //if (firstFrame) firstFrame = false; + + // wait for update & paint to happen before drawing next frame + // this is necessary since the drawing is sometimes in a + // separate thread, meaning that the next frame will start + // before the update/paint is completed + //while (!updated) { + try { + if (THREAD_DEBUG) println(Thread.currentThread().getName() + + " " + looping + " " + redraw); + //Thread.yield(); + // windows doesn't like 'yield', so have to sleep at least + // for some small amount of time. + if (THREAD_DEBUG) println(Thread.currentThread().getName() + + " gonna sleep"); + // can't remember when/why i changed that to '1' + // (rather than 3 or 5, as has been traditional), but i + // have a feeling that some platforms aren't gonna like that + // if !looping, sleeps for a nice long time + int nap = looping ? 1 : 10000; + // don't nap after setup, because if noLoop() is called this + // will make the first draw wait 10 seconds before showing up + if (frameCount == 1) nap = 1; + Thread.sleep(nap); + if (THREAD_DEBUG) println(Thread.currentThread().getName() + + " outta sleep"); + } catch (InterruptedException e) { } + //} + } + + } catch (Exception e) { + // formerly in kjcapplet, now just checks to see + // if someone wants to leech off errors + + // note that this will not catch errors inside setup() + // those are caught by the PdeRuntime + + System.out.println("exception occurred (if you don't see a stack " + + "trace below this message, we've got a bug)"); + finished = true; + exception = e; + //e.printStackTrace(System.out); + + if (leechErr != null) { + // if draw() mode, make sure that ui stops waiting + // and the run button quits out + leechErr.println(LEECH_WAKEUP); + e.printStackTrace(leechErr); + + } else { + System.err.println(LEECH_WAKEUP); + e.printStackTrace(); + } + } + if (THREAD_DEBUG) println(Thread.currentThread().getName() + + " thread finished"); + //System.out.println("exiting run " + finished); + stop(); // call to shutdown libs? + } + + + public void display() { if (PApplet.THREAD_DEBUG) println(Thread.currentThread().getName() + " formerly nextFrame()"); - //if (looping || redraw) nextFrame(); if (looping || redraw) { + /* if (frameCount == 0) { // needed here for the sync - createGraphics(); + //createGraphics(); + // set up a dummy graphics in case size() is never + // called inside setup + size(INITIAL_WIDTH, INITIAL_HEIGHT); } + */ // g may be rebuilt inside here, so turning of the sync //synchronized (g) { @@ -647,28 +975,56 @@ public class PApplet extends Applet " 1b draw"); if (frameCount == 0) { - //initGraphics(); - //createGraphics(); g.defaults(); - setup(); + + try { + //System.out.println("attempting setup"); + //System.out.println("into try"); + setup(); + //System.out.println("done attempting setup"); + //System.out.println("out of try"); + + } catch (RuntimeException e) { + //System.out.println("catching a cold " + e.getMessage()); + if (e.getMessage().indexOf(NEW_RENDERER) != -1) { + //System.out.println("got new renderer"); + return; + //continue; // will this work? + + } else { + throw e; + } + } // if depth() is called inside setup, pixels/width/height // will be ok by the time it's back out again - this.pixels = g.pixels; + //this.pixels = g.pixels; // make em call loadPixels + // now for certain that we've got a valid size this.width = g.width; this.height = g.height; } else { - if (fpsTarget != 0) { - if (fpsLastDelayTime == 0) { - fpsLastDelayTime = System.currentTimeMillis(); + // update the current framerate + if (framerateLastMillis != 0) { + float elapsed = (float) + (System.currentTimeMillis() - framerateLastMillis); + if (elapsed != 0) { + framerate = + (framerate * 0.9f) + ((1.0f / (elapsed / 1000.0f)) * 0.1f); + } + } + framerateLastMillis = System.currentTimeMillis(); + + if (framerateTarget != 0) { + if (framerateLastDelayTime == 0) { + framerateLastDelayTime = System.currentTimeMillis(); } else { long timeToLeave = - fpsLastDelayTime + (long)(1000.0f / fpsTarget); + framerateLastDelayTime + (long)(1000.0f / framerateTarget); int napTime = (int) (timeToLeave - System.currentTimeMillis()); - fpsLastDelayTime = timeToLeave; + framerateLastDelayTime = timeToLeave; delay(napTime); } } @@ -735,65 +1091,6 @@ public class PApplet extends Applet //} } // end of synchronize } - - // moving this to update() (for 0069+) for linux sync problems - //if (firstFrame) firstFrame = false; - - // wait for update & paint to happen before drawing next frame - // this is necessary since the drawing is sometimes in a - // separate thread, meaning that the next frame will start - // before the update/paint is completed - //while (!updated) { - try { - if (THREAD_DEBUG) println(Thread.currentThread().getName() + - " " + looping + " " + redraw); - //Thread.yield(); - // windows doesn't like 'yield', so have to sleep at least - // for some small amount of time. - if (THREAD_DEBUG) println(Thread.currentThread().getName() + - " gonna sleep"); - // can't remember when/why i changed that to '1' - // (rather than 3 or 5, as has been traditional), but i - // have a feeling that some platforms aren't gonna like that - // if !looping, sleeps for a nice long time - int nap = looping ? 1 : 10000; - // don't nap after setup, because if noLoop() is called this - // will make the first draw wait 10 seconds before showing up - if (frameCount == 1) nap = 1; - Thread.sleep(nap); - if (THREAD_DEBUG) println(Thread.currentThread().getName() + - " outta sleep"); - } catch (InterruptedException e) { } - //} - } - - } catch (Exception e) { - // formerly in kjcapplet, now just checks to see - // if someone wants to leech off errors - - // note that this will not catch errors inside setup() - // those are caught by the PdeRuntime - - System.out.println("exception occurred (if you don't see a stack " + - "trace below this message, we've got a bug)"); - finished = true; - //e.printStackTrace(System.out); - - if (leechErr != null) { - // if draw() mode, make sure that ui stops waiting - // and the run button quits out - leechErr.println(LEECH_WAKEUP); - e.printStackTrace(leechErr); - - } else { - System.err.println(LEECH_WAKEUP); - e.printStackTrace(); - } - } - if (THREAD_DEBUG) println(Thread.currentThread().getName() + - " thread finished"); - //System.out.println("exiting run " + finished); - stop(); // call to shutdown libs? } @@ -1046,11 +1343,11 @@ public class PApplet extends Applet /** * Called each time a single key on the keyboard is pressed. - * + *
* Examples for key handling: * (Tested on Windows XP, please notify if different on other * platforms, I have a feeling Mac OS and Linux may do otherwise) - * + *
* 1. Pressing 'a' on the keyboard:
* keyPressed with key == 'a' and keyCode == 'A'
* keyTyped with key == 'a' and keyCode == 0
@@ -1086,6 +1383,7 @@ public class PApplet extends Applet
* this behavior off if Java 1.4 is in use (tested 1.4.2_05 Windows).
* Java 1.1 (Microsoft VM) passes the TAB key through normally.
* Not tested on other platforms or for 1.3.
+ *
*/
public void keyPressed() { }
@@ -1131,7 +1429,12 @@ public class PApplet extends Applet
// getting the time
- /** Get the number of milliseconds since the applet started. */
+ /**
+ * Get the number of milliseconds since the applet started.
+ * + * This is a function, rather than a variable, because it may + * change multiple times per frame. + */ public int millis() { return (int) (System.currentTimeMillis() - millisOffset); } @@ -1146,13 +1449,20 @@ public class PApplet extends Applet return Calendar.getInstance().get(Calendar.MINUTE); } - /** Hour position of the current time. */ + /** + * Hour position of the current time in international format (0-23). + *
+ * To convert this value to American time:
+ *
int yankeeHour = (hour() % 12); + * if (yankeeHour == 0) yankeeHour = 12;+ */ static public int hour() { return Calendar.getInstance().get(Calendar.HOUR_OF_DAY); } /** * Get the current day of the month (1 through 31). + *
* If you're looking for the day of the week (M-F or whatever) * or day of the year (1..365) then use java's Calendar.get() */ @@ -1194,31 +1504,12 @@ public class PApplet extends Applet } - /** - * Get the current framerate. The initial value will be 10 fps, - * and will be updated with each frame thereafter. The value is not - * instantaneous (since that wouldn't be very useful since it would - * jump around so much), but is instead averaged (integrated) - * over roughly the last 10 frames. - */ - public float framerate() { - if (fpsLastMillis != 0) { - float elapsed = (float) (System.currentTimeMillis() - fpsLastMillis); - if (elapsed != 0) { - fps = (fps * 0.9f) + ((1.0f / (elapsed / 1000.0f)) * 0.1f); - } - } - fpsLastMillis = System.currentTimeMillis(); - return fps; - } - - /** * Set a target framerate. This will cause delay() to be called * after each frame to allow for a specific rate to be set. */ - public void framerate(float fpsTarget) { - this.fpsTarget = fpsTarget; + public void framerate(float framerateTarget) { + this.framerateTarget = framerateTarget; } @@ -3234,17 +3525,25 @@ public class PApplet extends Applet */ } + /** + * Join an array of Strings together as a single String, + * separated by the whatever's passed in for the separator. + */ + static public String join(String str[], char separator) { + return join(str, String.valueOf(separator)); + } + /** * Join an array of Strings together as a single String, * separated by the whatever's passed in for the separator. - * + *
* To use this on numbers, first pass the array to nf() or nfs() * to get a list of String objects, then use join on that. - * + *
* e.g. String stuff[] = { "apple", "bear", "cat" };
* String list = join(stuff, ", ");
- * // list is now "apple, bear, cat"
+ * // list is now "apple, bear, cat"
*/
static public String join(String str[], String separator) {
StringBuffer buffer = new StringBuffer();
@@ -3260,16 +3559,16 @@ public class PApplet extends Applet
* Split the provided String at wherever whitespace occurs.
* Multiple whitespace (extra spaces or tabs or whatever)
* between items will count as a single break.
- *
+ * * The whitespace characters are "\t\n\r\f", which are the defaults * for java.util.StringTokenizer, plus the unicode non-breaking space * character, which is found commonly on files created by or used * in conjunction with Mac OS X (character 160, or 0x00A0 in hex). - * + *
* i.e. split("a b") -> { "a", "b" }
* split("a b") -> { "a", "b" }
* split("a\tb") -> { "a", "b" }
- * split("a \t b ") -> { "a", "b" }
+ * split("a \t b ") -> { "a", "b" }
*/
static public String[] split(String what) {
return split(what, WHITESPACE);
@@ -3282,13 +3581,13 @@ public class PApplet extends Applet
* in addition to white space, you might want to treat commas
* as a separator. The delimeter characters won't appear in
* the returned String array.
- *
+ *
* i.e. split("a, b", " ,") -> { "a", "b" }
- *
+ *
* To include all the whitespace possibilities, use the variable
* WHITESPACE, found in PConstants:
- *
- * i.e. split("a | b", WHITESPACE + "|"); -> { "a", "b" }
+ *
+ * i.e. split("a | b", WHITESPACE + "|"); -> { "a", "b" }
*/
static public String[] split(String what, String delim) {
StringTokenizer toker = new StringTokenizer(what, delim);
@@ -3305,7 +3604,7 @@ public class PApplet extends Applet
/**
* Split a string into pieces along a specific character.
* Most commonly used to break up a String along tab characters.
- *
+ * * This operates differently than the others, where the * single delimeter is the only breaking point, and consecutive * delimeters will produce an empty string (""). This way, @@ -4301,170 +4600,259 @@ v PApplet.this.stop(); } + /** + * The simplest way to turn and applet into an application is to + * add the following code to your program: + *
static public void main(String args[]) {
+ * PApplet.main(new String[] { "YourSketchName" };
+ * }
+ * This will properly launch your applet from a double-clickable
+ * .jar or from the command line.
+ *
+ * Parameters useful for launching or also used by the PDE:
+ *
+ * --location=x,y upper-lefthand corner of where the applet
+ * should appear on screen. if not used,
+ * the default is to center on the main screen.
+ *
+ * --present put the applet into full screen presentation
+ * mode. requires java 1.4.
+ *
+ * --present-color background color of the presentation window
+ *
+ * --sketch-folder location of where to save files from functions
+ * like saveStrings() or saveFrame(). defaults to
+ * the folder that the java application was
+ * launched from, which means if this isn't set by
+ * the pde, everything goes into the same folder
+ * as processing.exe.
+ *
+ * --display=n set what display should be used by this applet.
+ * displays are numbered starting from 1.
+ *
+ *
+ * Parameters used by Processing when running an applet externally:
+ *
+ * --external set when the applet is being used by the PDE
+ *
+ * --editor-location=x,y position of the upper-lefthand corner of the
+ * editor window, for placement of applet window
+ *
+ * --present-stop-color color of the 'stop' text used to quit an
+ * applet when it's in present mode.
+ */
static public void main(String args[]) {
if (args.length < 1) {
- System.err.println("error: PApplet ");
+ System.err.println("Usage: PApplet ");
System.exit(1);
}
try {
boolean external = false;
int location[] = null;
- //int locationX, locationY;
- boolean exactLocation = false;
+ int editorLocation[] = null;
+ //boolean exactLocation = false;
String folder = System.getProperty("user.dir");
- //if (args[0].indexOf(EXTERNAL_FLAG) == 0) external = true;
String name = null;
+ boolean present = false;
+ Color presentColor = Color.BLACK;
+ Color stopColor = Color.GRAY;
+ //Object displayDevice = null;
+ GraphicsDevice displayDevice = null;
- int initialWidth = PApplet.DEFAULT_WIDTH;
- int initialHeight = PApplet.DEFAULT_HEIGHT;
+ String param = null, value = null;
int argIndex = 0;
while (argIndex < args.length) {
- if (args[argIndex].indexOf(EXT_LOCATION) == 0) {
- external = true;
- String locationStr =
- args[argIndex].substring(EXT_LOCATION.length());
- location = toInt(split(locationStr, ','));
- //locationX = location[0] - 20;
- //locationY = location[1];
+ int equals = args[argIndex].indexOf('=');
+ if (equals != -1) {
+ param = args[argIndex].substring(0, equals);
+ value = args[argIndex].substring(equals + 1);
- } else if (args[argIndex].indexOf(EXT_EXACT_LOCATION) == 0) {
- external = true;
- String locationStr =
- args[argIndex].substring(EXT_EXACT_LOCATION.length());
- location = toInt(split(locationStr, ','));
- exactLocation = true;
+ if (param.equals(ARGS_EDITOR_LOCATION)) {
+ external = true;
+ editorLocation = toInt(split(value, ','));
- } else if (args[argIndex].indexOf(EXT_SKETCH_FOLDER) == 0) {
- folder = args[argIndex].substring(EXT_SKETCH_FOLDER.length());
+ } else if (param.equals(ARGS_DISPLAY)) {
+ int deviceIndex = Integer.parseInt(value) - 1;
- } else if (args[argIndex].indexOf(EXT_SIZE) == 0) {
- String sizeStr = args[argIndex].substring(EXT_SIZE.length());
- int initial[] = toInt(split(sizeStr, ','));
- initialWidth = initial[0];
- initialHeight = initial[1];
- //System.out.println("initial: " + initialWidth + " " + initialHeight);
+ GraphicsEnvironment environment =
+ GraphicsEnvironment.getLocalGraphicsEnvironment();
+ GraphicsDevice devices[] = environment.getScreenDevices();
+ if ((deviceIndex >= 0) && (deviceIndex < devices.length)) {
+ displayDevice = devices[deviceIndex];
+ } else {
+ System.err.println("Display " + value + " does not exist, " +
+ "using the default display instead.");
+ }
+
+ } else if (param.equals(ARGS_PRESENT_BGCOLOR)) {
+ if (value.charAt(0) == '#') value = value.substring(1);
+ presentColor = new Color(Integer.parseInt(value, 16));
+
+ } else if (param.equals(ARGS_PRESENT_STOP_COLOR)) {
+ if (value.charAt(0) == '#') value = value.substring(1);
+ stopColor = new Color(Integer.parseInt(value, 16));
+
+ } else if (param.equals(ARGS_SKETCH_FOLDER)) {
+ folder = value;
+
+ } else if (param.equals(ARGS_LOCATION)) {
+ location = toInt(split(value, ','));
+ }
} else {
- name = args[argIndex];
- break;
+ if (args[argIndex].equals(ARGS_PRESENT)) {
+ present = true;
+
+ } else if (args[argIndex].equals(ARGS_EXTERNAL)) {
+ external = true;
+
+ } else {
+ name = args[argIndex];
+ break;
+ }
}
argIndex++;
}
- Frame frame = new Frame();
+ Frame frame = null; //new Frame();
+ if (displayDevice != null) {
+ //GraphicsConfiguration gc = displayDevice.getDefaultConfiguration();
+ //frame = new Frame(gc);
+ frame = new Frame(displayDevice.getDefaultConfiguration());
+ } else {
+ frame = new Frame();
+ }
+
frame.setResizable(false); // remove the grow box
- frame.pack(); // get insets. get more.
- //frame.show(); // gl hack
+ //frame.pack(); // get insets. get more.
Class c = Class.forName(name);
PApplet applet = (PApplet) c.newInstance();
- applet.frame = frame;
-
- applet.INITIAL_WIDTH = initialWidth;
- applet.INITIAL_HEIGHT = initialHeight;
// these are needed before init/start
+ applet.frame = frame;
applet.folder = folder;
- int argc = args.length - (argIndex+1);
- applet.args = new String[argc];
- System.arraycopy(args, argc, applet.args, 0, argc);
+ applet.args = PApplet.subset(args, 1);
- //System.out.println("calling applet.init");
applet.init();
- //applet.start();
- //System.out.println("done calling applet.init");
- Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
+ // wait until the applet has figured out its width
+ // hoping that this won't hang if the applet has an exception
+ while ((applet.width == 0) && !applet.finished) {
+ try {
+ Thread.sleep(5);
- if (external) {
- Insets insets = frame.getInsets(); // does pack() first above
- //System.out.println(insets);
+ } catch (InterruptedException e) { }
+ }
- int locationX = location[0] - 20;
- int locationY = location[1];
+ if (present) {
+ frame.setUndecorated(true);
+ //frame.setResizable(false);
- // applet.width and .height are zero here
- /*
- int minW = 120;
- int minH = 120;
- int windowW =
- Math.max(applet.width, minW) + insets.left + insets.right;
- int windowH =
- Math.max(applet.height, minH) + insets.top + insets.bottom;
- */
- //int windowW = 120 + insets.left + insets.right;
- //int windowH = 120 + insets.top + insets.bottom;
- int windowW = initialWidth + insets.left + insets.right;
- int windowH = initialHeight + insets.top + insets.bottom;
- frame.setSize(windowW, windowH);
+ //DisplayMode dm = device.getDisplayMode();
+ //if ((dm.getWidth() == 1024) && (dm.getHeight() == 768)) {
- if (exactLocation) {
- frame.setLocation(location[0], location[1]);
+ //if (presentColor != null) {
+ frame.setBackground(presentColor);
+ //}
+ displayDevice.setFullScreenWindow(frame);
- } else {
- if (locationX - windowW > 10) {
- // if it fits to the left of the window
- frame.setLocation(locationX - windowW, locationY);
-
- } else {
- // if it fits inside the editor window,
- // offset slightly from upper lefthand corner
- // so that it's plunked inside the text area
- locationX = location[0] + 66;
- locationY = location[1] + 66;
-
- if ((locationX + windowW > screen.width - 33) ||
- (locationY + windowH > screen.height - 33)) {
- // otherwise center on screen
- locationX = (screen.width - windowW) / 2;
- locationY = (screen.height - windowH) / 2;
- }
- frame.setLocation(locationX, locationY);
- }
- }
- //System.out.println("applet izzat: " + applet.width + " " +
- // applet.height);
-
- frame.setLayout(null);
frame.add(applet);
- frame.setBackground(SystemColor.control);
- /*
- applet.setBounds((windowW - applet.width)/2,
- insets.top + ((windowH - insets.top - insets.bottom) -
- applet.height)/2,
- windowW, windowH);
- */
- applet.setBounds((windowW - initialWidth) / 2,
- insets.top + ((windowH - insets.top -
- insets.bottom) - initialHeight)/2,
- windowW, windowH);
+ Dimension fullscreen = frame.getSize();
+ //System.out.println("screen size is " + screen);
+ applet.setBounds((fullscreen.width - applet.width) / 2,
+ (fullscreen.height - applet.height) / 2,
+ applet.width, applet.height);
- applet.setupExternal(frame);
+ if (external) {
+ Label label = new Label("stop");
+ label.setForeground(stopColor);
+ label.addMouseListener(new MouseAdapter() {
+ public void mousePressed(MouseEvent e) {
+ System.exit(0);
+ }
+ });
+ frame.add(label);
+ Dimension labelSize = label.getPreferredSize();
+ label.setSize(labelSize);
+ //label.setLocation(20, 40);
+ label.setLocation(20, fullscreen.height - labelSize.height - 20);
+ applet.setupExternal(frame);
+ }
- } else { // !external
- //System.out.println("applet not external");
-
- // remove applet name from args passed in
- applet.args = new String[args.length - 1];
- System.arraycopy(args, 1, applet.args, 0, args.length - 1);
-
- frame.setLayout(new BorderLayout());
- frame.add(applet, BorderLayout.CENTER);
+ } else { // if not presenting
+ // can't do this earlier cuz present mode don't like it
frame.pack();
- frame.setLocation((screen.width - applet.g.width) / 2,
- (screen.height - applet.g.height) / 2);
+ if (external) {
+ Insets insets = frame.getInsets(); // does pack() first above
- frame.addWindowListener(new WindowAdapter() {
- public void windowClosing(WindowEvent e) {
- System.exit(0);
+ int windowW =
+ Math.max(applet.width, 120) + insets.left + insets.right;
+ int windowH =
+ Math.max(applet.height, 120) + insets.top + insets.bottom;
+ frame.setSize(windowW, windowH);
+
+ if (location != null) {
+ // a specific location was received from PdeRuntime
+ // (applet has been run more than once, user placed window)
+ frame.setLocation(location[0], location[1]);
+
+ } else {
+ int locationX = editorLocation[0] - 20;
+ int locationY = editorLocation[1];
+
+ if (locationX - windowW > 10) {
+ // if it fits to the left of the window
+ frame.setLocation(locationX - windowW, locationY);
+
+ } else {
+ // if it fits inside the editor window,
+ // offset slightly from upper lefthand corner
+ // so that it's plunked inside the text area
+ locationX = editorLocation[0] + 66;
+ locationY = editorLocation[1] + 66;
+
+ if ((locationX + windowW > screen.width - 33) ||
+ (locationY + windowH > screen.height - 33)) {
+ // otherwise center on screen
+ locationX = (screen.width - windowW) / 2;
+ locationY = (screen.height - windowH) / 2;
+ }
+ frame.setLocation(locationX, locationY);
}
- });
+ }
+
+ frame.setLayout(null);
+ frame.add(applet);
+ frame.setBackground(SystemColor.control);
+ int usableWindowH = windowH - insets.top - insets.bottom;
+ applet.setBounds((windowW - applet.width)/2,
+ insets.top + (usableWindowH - applet.height)/2,
+ windowW, windowH);
+ applet.setupExternal(frame);
+
+ } else { // !external
+ frame.setLayout(new BorderLayout());
+ frame.add(applet, BorderLayout.CENTER);
+ //frame.pack(); // is this necessary?
+
+ frame.setLocation((screen.width - applet.width) / 2,
+ (screen.height - applet.height) / 2);
+
+ frame.addWindowListener(new WindowAdapter() {
+ public void windowClosing(WindowEvent e) {
+ System.exit(0);
+ }
+ });
+ }
+
+ frame.show();
}
+
//System.out.println("showing frame");
- frame.show();
//System.out.println("applet requesting focus");
applet.requestFocus(); // ask for keydowns
//System.out.println("exiting main()");
@@ -4479,7 +4867,7 @@ v PApplet.this.stop();
//////////////////////////////////////////////////////////////
- public void recordFrame(PMethods recorder) {
+ public void recordFrame(PGraphics recorder) {
this.recorder = recorder;
recorder.beginFrame();
}
@@ -4494,15 +4882,15 @@ v PApplet.this.stop();
}
- public void updatePixels() {
+ //public void updatePixels() {
// anything special here?
- g.updatePixels();
- }
+ //g.updatePixels();
+ //}
- public void updatePixels(int x1, int y1, int x2, int y2) {
- g.updatePixels(x1, y1, x2, y2);
- }
+ //public void updatePixels(int x1, int y1, int x2, int y2) {
+ //g.updatePixels(x1, y1, x2, y2);
+ //}
//////////////////////////////////////////////////////////////
@@ -4529,6 +4917,18 @@ v PApplet.this.stop();
}
+ public void updatePixels() {
+ if (recorder != null) recorder.updatePixels();
+ g.updatePixels();
+ }
+
+
+ public void updatePixels(int x1, int y1, int x2, int y2) {
+ if (recorder != null) recorder.updatePixels(x1, y1, x2, y2);
+ g.updatePixels(x1, y1, x2, y2);
+ }
+
+
public int get(int x, int y) {
return g.get(x, y);
}
@@ -4652,6 +5052,12 @@ v PApplet.this.stop();
}
+ public void requestDisplay(PApplet parent) {
+ if (recorder != null) recorder.requestDisplay(parent);
+ g.requestDisplay(parent);
+ }
+
+
public void hint(int which) {
if (recorder != null) recorder.hint(which);
g.hint(which);
diff --git a/core/PConstants.java b/core/PConstants.java
index 4d46858c3..19482c20d 100644
--- a/core/PConstants.java
+++ b/core/PConstants.java
@@ -31,6 +31,23 @@ import java.awt.event.KeyEvent;
public interface PConstants {
+ // renderers known to processing.core
+
+ static final String P2D = "processing.core.PGraphics";
+ static final String P3D = "processing.core.PGraphics3";
+ static final String JAVA2D = "processing.core.PGraphics2";
+ static final String OPENGL = "processing.opengl.PGraphicsGL";
+
+
+ // platform IDs for PApplet.platform
+
+ static final int WINDOWS = 1;
+ static final int MACOS9 = 2;
+ static final int MACOSX = 3;
+ static final int LINUX = 4;
+ static final int OTHER = 0;
+
+
// for better parity between c++ version (at no speed cost)
static final float EPSILON = 0.0001f;
diff --git a/core/PGraphics.java b/core/PGraphics.java
index 9cce84ddc..86a94a60a 100644
--- a/core/PGraphics.java
+++ b/core/PGraphics.java
@@ -296,8 +296,8 @@ public class PGraphics extends PImage implements PConstants {
* @param iwidth viewport width
* @param iheight viewport height
*/
- public PGraphics(int iwidth, int iheight) {
- resize(iwidth, iheight);
+ //public PGraphics(int iwidth, int iheight) {
+ //resize(iwidth, iheight);
// init color/stroke/fill
// called instead just before setup on first frame
@@ -306,6 +306,26 @@ public class PGraphics extends PImage implements PConstants {
// clear geometry for loading later
//circleX = null; // so that bagel knows to init these
//sphereX = null; // diff from cpp b/c mem in cpp is preallocated
+ //}
+
+
+ /**
+ * Constructor for the PGraphics object. Use this to ensure that
+ * the defaults get set properly. In a subclass, use this(w, h)
+ * as the first line of a subclass' constructor to properly set
+ * the internal fields and defaults.
+ *
+ * @param iwidth viewport width
+ * @param iheight viewport height
+ */
+ public PGraphics(int iwidth, int iheight, PApplet applet) {
+ if (applet != null) {
+ applet.addMouseListener(applet);
+ applet.addMouseMotionListener(applet);
+ applet.addKeyListener(applet);
+ applet.addFocusListener(applet);
+ }
+ resize(iwidth, iheight);
}
@@ -313,7 +333,7 @@ public class PGraphics extends PImage implements PConstants {
* Called in repsonse to a resize event, handles setting the
* new width and height internally, as well as re-allocating
* the pixel buffer for the new size.
- *
+ *
* Note that this will nuke any cameraMode() settings.
*/
public void resize(int iwidth, int iheight) { // ignore
@@ -331,6 +351,14 @@ public class PGraphics extends PImage implements PConstants {
}
+ /**
+ * Parent thread has requested that visual action be taken.
+ */
+ public void requestDisplay(PApplet parent) {
+ parent.display();
+ }
+
+
// broken out because of subclassing
protected void allocate() {
pixelCount = width * height;
@@ -387,6 +415,7 @@ public class PGraphics extends PImage implements PConstants {
* set engine's default values
*/
public void defaults() { // ignore
+ //System.out.println("PGraphics.defaults()");
colorMode(RGB, TFF);
fill(TFF);
stroke(0);
diff --git a/core/PGraphics2.java b/core/PGraphics2.java
index f25bff300..c0801f622 100644
--- a/core/PGraphics2.java
+++ b/core/PGraphics2.java
@@ -74,8 +74,9 @@ public class PGraphics2 extends PGraphics {
* @param iwidth viewport width
* @param iheight viewport height
*/
- public PGraphics2(int iwidth, int iheight) {
- resize(iwidth, iheight);
+ public PGraphics2(int iwidth, int iheight, PApplet parent) {
+ super(iwidth, iheight, parent);
+ //resize(iwidth, iheight);
}
@@ -1048,11 +1049,23 @@ public class PGraphics2 extends PGraphics {
}
+ /**
+ * Update the pixels[] buffer to the PGraphics image.
+ *
+ * Unlike in PImage, where updatePixels() only asks that the
+ * update happens, in PGraphics2, this will happen immediately.
+ */
public void updatePixels() {
updatePixels(0, 0, width, height);
}
+ /**
+ * Update the pixels[] buffer to the PGraphics image.
+ *
+ * Unlike in PImage, where updatePixels() only asks that the
+ * update happens, in PGraphics2, this will happen immediately.
+ */
public void updatePixels(int x, int y, int c, int d) {
((BufferedImage) image).setRGB(x, y,
(imageMode == CORNER) ? c : (c - x),
diff --git a/core/PGraphics3.java b/core/PGraphics3.java
index 9387f6d9f..e8ea7313a 100644
--- a/core/PGraphics3.java
+++ b/core/PGraphics3.java
@@ -184,8 +184,9 @@ public class PGraphics3 extends PGraphics {
* @param iwidth viewport width
* @param iheight viewport height
*/
- public PGraphics3(int iwidth, int iheight) {
- resize(iwidth, iheight);
+ public PGraphics3(int iwidth, int iheight, PApplet parent) {
+ super(iwidth, iheight, parent);
+ //resize(iwidth, iheight);
}
@@ -197,6 +198,8 @@ public class PGraphics3 extends PGraphics {
* Note that this will nuke any cameraMode() settings.
*/
public void resize(int iwidth, int iheight) { // ignore
+ //System.out.println("PGraphics3 resize");
+
width = iwidth;
height = iheight;
width1 = width - 1;
@@ -233,7 +236,8 @@ public class PGraphics3 extends PGraphics {
// reset the cameraMode if PERSPECTIVE or ORTHOGRAPHIC
// will just be ignored if CUSTOM, the user's hosed anyways
- cameraMode(this.cameraMode);
+ //System.out.println("setting cameraMode to " + cameraMode);
+ if (this.cameraMode != CUSTOM) cameraMode(this.cameraMode);
}
@@ -305,6 +309,8 @@ public class PGraphics3 extends PGraphics {
public void defaults() {
+ //System.out.println("PGraphics3.defaults() top");
+
super.defaults();
cameraMode(PERSPECTIVE);
@@ -2272,7 +2278,8 @@ public class PGraphics3 extends PGraphics {
endCamera();
}
- cameraMode = mode; // this doesn't do much
+ cameraMode = mode;
+ //System.out.println("camera mode is now " + cameraMode);
}
diff --git a/core/PImage.java b/core/PImage.java
index d9770f88b..e22bccfac 100644
--- a/core/PImage.java
+++ b/core/PImage.java
@@ -315,16 +315,20 @@ public class PImage implements PConstants, Cloneable {
/**
* Mark all pixels as needing update.
*/
- public void updatePixels() { // ignore
+ public void updatePixels() {
updatePixels(0, 0, width, height);
}
/**
+ * Mark the pixels in this region as needing an update.
+ *
+ * This doesn't take into account
+ *
* Note that when using imageMode(CORNERS),
* the x2 and y2 positions are non-inclusive.
*/
- public void updatePixels(int x1, int y1, int x2, int y2) { // ignore
+ public void updatePixels(int x1, int y1, int x2, int y2) {
//if (!modified) { // could just set directly, but..
//}
@@ -602,6 +606,9 @@ public class PImage implements PConstants, Cloneable {
*
filter(OPAQUE) set all the high bits in the image to opaque
* filter(THRESHOLD) converts the image to black and white.
*
+ *
+ * Gaussian blur code contributed by Mario Klingemann
+ * http://incubator.quasimondo.com
*/
public void filter(int kind) {
switch (kind) {
@@ -666,6 +673,9 @@ public class PImage implements PConstants, Cloneable {
* filter(THRESHOLD, float center) allows you to set the
* center point for the threshold. It takes a value from 0 to 1.0.
*
+ *
+ * Gaussian blur code contributed by Mario Klingemann
+ * http://incubator.quasimondo.com
*/
public void filter(int kind, float param) {
switch (kind) {
diff --git a/core/todo.txt b/core/todo.txt
index e902d20b2..00549fc2c 100644
--- a/core/todo.txt
+++ b/core/todo.txt
@@ -1,4 +1,69 @@
0081 core
+X background(PImage) now works in opengl
+X when running externally, applets don't always get placed properly
+X if size is never set, then doesn't always layout
+X problem is in gl and in core, and is inconsistent
+X move more logic for layout into PApplet.. maybe a static method?
+X this way can avoid duplicating / breaking things
+o what is the stroked version of a sphere? a circle?
+X write list of params that can be passed to PApplet
+o document in the code a note about how size() et al place themselves
+
+size(200, 200, P3D) - createGraphics and placement issues
+X make pappletgl work back inside papplet
+X and then size(300, 300, DEPTH) etc
+X get rid of opengl renderer menu
+o otherwise hint() to use the p5 renderer instead of java2d
+X applet placement is screwy
+X how to force PGraphics() instead of PGraphics2()
+X size(300, 200, P2D);
+X size() doing a setBounds() is really bad
+X because it means things can't be embedded properly
+o applets on osx (and windows) sometimes show up 20 pixels off the top
+X how to shut off rendering to screen when illustrator in use?
+X need size(30000, 20000) for illustrator, problem in papplet
+X size(30000, 20000, ILLUSTRATOR)
+X make Graphics2 et al load dynamically using reflection
+X can this be done with g2 and if exception just falls back to g1?
+X this way people can remove g1 by hand
+o size() that changes renderer will throw nasty exception in draw()
+X or maybe that's ok? document that no changing renderers?
+
+present mode
+o call present() from inside the code?
+o that if applet is 500x500, centers on a 800x600 window
+X no, that's nasty... use --present to launch in present window
+X though how do you get the screen size?
+X screen.width and screen.height? - yes
+X write java 1.4 code for full screen version of PApplet
+X this might be used for presentation mode
+X proper full screen code for present mode
+X why do mouse motion events go away in full screen mode
+X or with a Window object
+X use screen manager to run present mode properly
+X set both versions to require java 1.4
+X change the Info.plist inside macosx
+X and add something to PdeBase to make sure that it's in 1.4
+X running present mode with a bug in the program hoses things
+X make sure the program compiles before starting present mode
+
+_ fix the flicker in java2d mode
+X is it because the lock was taken off (g) in PApplet?
+
+_ cellular automata examples broken
+
+_ gl smoothing.. how to disable polygon but keep line enabled
+_ or at least make a note of this?
+_ leave smooth off, get the gl object, then enable line smooth
+
+_ gl points not working again
+
+_ implement full screen mode.. this takes over the screen as best it can
+_ size(screen.width, screen.height, OPENGL);
+_ if size is screen.width and screen.height, does its best
+_ needs to get the size of the main screen
+
+_ make illustrator lib
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
@@ -13,61 +78,17 @@ _ don't grab pixels of java2d images unless asked
_ this is the difference between a lot of loadPixels() and not
_ so important to have it in before beta if that's the change
-_ new PGraphics(PImage)
+_ get PGraphics.java engine working again
+
_ if (modified) don't loadPixels again, just ignore it
_ make a note that updatePixels() only sets a flag in PImage
_ (but not PGraphics, which does it immediately)
-_ get PGraphics.java engine working again
-
_ remove PMethods as actual class, use recordFrame(PGraphics)
_ size(200, 200, "processing.illustrator.PGraphicsAI");
_ make vertexCount etc properly accessible in PGraphics3
_ so that people can do things like the dxf renderer
-size(200, 200, P3D) - createGraphics and placement issues
-_ make pappletgl work back inside papplet
-_ and then size(300, 300, DEPTH) etc
-_ get rid of opengl renderer menu
-o otherwise hint() to use the p5 renderer instead of java2d
-_ applet placement is screwy
-X how to force PGraphics() instead of PGraphics2()
-_ size(300, 200, P2D);
-_ size() doing a setBounds() is really bad
-_ because it means things can't be embedded properly
-o applets on osx (and windows) sometimes show up 20 pixels off the top
-X how to shut off rendering to screen when illustrator in use?
-X need size(30000, 20000) for illustrator, problem in papplet
-_ size(30000, 20000, ILLUSTRATOR)
-o implement fullsize().. this takes over the screen as best it can
-_ size(screen.width, screen.height, OPENGL);
-_ make Graphics2 et al load dynamically using reflection
-_ can this be done with g2 and if exception just falls back to g1?
-_ this way people can remove g1 by hand
-
-present mode
-o call present() from inside the code?
-o that if applet is 500x500, centers on a 800x600 window
-X no, that's nasty... use --present to launch in present window
-X though how do you get the screen size?
-X screen.width and screen.height? - yes
-_ write java 1.3 code for full screen version of PApplet
-_ this might be used for presentation mode
-_ proper full screen code for present mode
-_ why do mouse motion events go away in full screen mode
-_ or with a Window object
-_ fix the flicker in java2d mode
-X is it because the lock was taken off (g) in PApplet?
-_ use screen manager to run present mode properly
-_ set both versions to require java 1.4
-_ change the Info.plist inside macosx
-_ and add something to PdeBase to make sure that it's in 1.4
-_ running present mode with a bug in the program hoses things
-_ make sure the program compiles before starting present mode
-_ ed's thread re: fullscreen strategies
-_ could add a new BApplet that uses BufferStrategy?
-_ http://processing.org/discourse/yabb/YaBB.cgi?board=Programs;action=display;num=1081335361;start=15
-
_ add something to PApplet to have constants for the platform
_ needed for error messages (don't talk about winvdig on mac)
_ and also useful for programs
@@ -111,6 +132,10 @@ _ actually, errors from many crashes not coming through on the mac?
_ allow save(), saveFrame() et al to properly pass in absolute paths
_ (so that it doesn't always save to the applet folder)
_ could require that save() takes an absolute path?
+_ size() inside draw is missing a new call to cameraMode, etc
+
+PGraphics
+_ new PGraphics(PImage)
PGraphics2
_ textSpace(SCREEN_SPACE) needs to be faster
@@ -175,8 +200,6 @@ _ for postscript, can grab the real font
_ -> altho problem here is that really the fonts just need a name
_ since needs to render to screen as well
-_ rewrite library/howto.txt to get rid of old interface
-
_ beginShape()
_ don't allow you to draw stroked items unless stroke() is called
_ don't allow beginShape() if shape is already set
@@ -192,12 +215,6 @@ _ 404 error because first searches applet directory on zipdecode
//
-_ when running externally, applets don't always get placed properly
-_ if size is never set, then doesn't always layout
-_ problem is in gl and in core, and is inconsistent
-_ move more logic for layout into PApplet.. maybe a static method?
-_ this way can avoid duplicating / breaking things
-
opengl
_ fix non-bound textures from mangling everything else
_ fix enable/disable textures for some objects
@@ -502,7 +519,6 @@ CORE / PApplet
1 _ problems with defining fill(255) vs fill(0xff808080)
1 _ http://processing.org/discourse/yabb/YaBB.cgi?board=Syntax;action=display;num=1083650609;start=0
1 _ http://processing.org/discourse/yabb/YaBB.cgi?board=Syntax;action=display;num=1082481891;start=2
- 1 _ what is the stroked version of a sphere? a circle?
1 _ too many push() will silently stop the applet inside a loop
1 _ test winding polygons in different directions
1 _ test lighting to see how it compares with gl
@@ -516,6 +532,9 @@ CORE / PApplet
1 _ attempting to download from another server
1 _ array utilities on Object[] are worthless.. fix it with reflection?
1 _ see if reflection will allow expand for all class types
+ 1 _ ed's thread re: fullscreen strategies
+ 1 _ could add a new BApplet that uses BufferStrategy?
+ 1 _ http://processing.org/discourse/yabb/YaBB.cgi?board=Programs;action=display;num=1081335361;start=15
CORE / Documentation
diff --git a/todo.txt b/todo.txt
index 1921926cc..668661405 100644
--- a/todo.txt
+++ b/todo.txt
@@ -1,21 +1,71 @@
0081 pde
+X need to make sure people add the OPENGL lib if using opengl mode
+X throws an error message
+o put processing.exe into cvs so that make et al aren't required
+o particles lib requires depth() (but shouldn't)
+o fix for 78 since not sure when simon's new version is happening
+X requires because uses 3D.. oh well
+o "draw" is not highlighted as a keyword.. other keywords?
+o draw(), PGraphics(), NO_DEPTH_TEST, PMovie(), PMovie.repeat()
+o PClient(), PClient.available(), PClient.read(),
+o PServer(), PServer.dispose(), PServer.write(), attach(), length
+o round() is not colored
+
+return flight from tokyo
+X make preferences a modal dialog
+X it's annoying when it hides itself
+X add editor font size in the preferences window
+X move the lib folders to a new location
+o libraries need to remove the PLibrary interface
+X fix bug where prefs were being applied even if cancel hit
+X the runtime environment requires java 1.4
+X make sure this is known and tested for properly
+X PdeRuntime/PApplet cleanup
+X run as external whenever using present mode
+X significantly limit range of cases.. if presenting ext is ok
+X uses internal pretty much only when single class, etc
+X remove initialWidth/Height stuff from PdeRuntime for when running internally
+
+_ when centering applet on-screen, needs to check for multiple screens
+_ this is both for PApplet and PdeRuntime
+_ PApplet screen size constant is no good
+
+_ check current present code with multiple monitors
+_ if it's working, make it all reflection-based in PApplet
+
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
MUST BE COMPLETE FOR BETA
-_ remove jvm from cvs
-_ use wget to grab it if it doesn't exist
-_ and include an md5hash to see if the file is correct
+
+non-coding tasks (for beta)
+_ new bboard? archive the old one, remove bugs sections
+_ environment reference
+_ consolidate readme.txt, revisions.txt
+_ bugzilla: move bugs.txt and todo.txt into bugzilla
+_ update processing/build/howto.txt
+_ add 'make' to list of things that should be installed
+_ update libraries/howto.txt
+_ should we queue lib events until the end of loop?
+_ nope, libraries can handle that themselves,
+_ and queue events by registering for draw or whatever they'd like
+_ lib could call queueEvent with the args
+_ then call them inside post()
+
+_ first pass on full screen
+_ exceptions in full screen mode will quit the app completely
+_ (can't keep window open because things are hosed)
+
+_ update checker (can be turned off in prefs)
+_ send unique id, and information about person's java vm/platform
+_ using timezone would be an interesting method for tracking location
+
+_ border weirdness in PdeEditor panels on windows
_ move everything to packages, and start auto-javadoc
-_ also move the lib folders to a new location
-
-_ better method of posting/handling bugs
-
-_ put processing.exe into cvs so that make et al aren't required
-_ add 'make' to list of things that should be installed
+_ remove PdeXxx prefixes on names, make PdeBase into just "Processing"
_ stop() not working very well
_ doesn't seem to actually be stopping things
@@ -28,14 +78,6 @@ _ something really bad happened with println() in this release
_ perhaps only without a code folder and/or running in java2d mode?
_ this may also be what's hosing
-_ PdeRuntime/PApplet cleanup
-_ run as external whenever using present mode
-_ significantly limit range of cases.. if presenting ext is ok
-_ uses internal pretty much only when single class, etc
-
-_ the runtime environment requires java 1.4
-_ make sure this is known and tested for properly
-
//
@@ -74,14 +116,34 @@ what happens if folder already exists on save as?
NOT NECESSARY BEFORE BETA
+_ split Preferences and PreferencesFrame ?
+
+_ properly handle ENTER, Ctrl-W and ESC on all dialogs
+_ there must be a proper "swing" way of doing this that doesn't
+_ involve adding key listeners to every friggin component
+_ ESC should fake a cancel button press
+_ ENTER should do the default option
+_ (might be a matter of setting the default action for the window?)
+
+secondary non-coding tasks (not before beta)
+_ move to new server
+_ javadoc everything
+
+_ when running as external applet, hide the editor text area
_ drag & drop implementation to add files to sketch
+_ remove jvm from cvs
+_ use wget to grab it if it doesn't exist
+_ and include an md5hash to see if the file is correct
+
_ straighten out int() -> toInt() conversion in the preproc
_ some type of sketch archive format for posting examples (.psk?)
_ would be nice to open a sketch directly from a zip file
camera
+_ when passing in 'null' as the camera, dialog pops up fine
+_ but the applet craps out after a few seconds (pinwheel spin)
_ list() should return full list with all sub-components
_ find the example code from the board
_ add prompt() method to Camera ("" means default, null is prompt)
@@ -107,27 +169,13 @@ _ openStream returning 'null' really horked up the letters applet
_ no System.out was coming through
_ System.err was getting cut off before finishing
-libraries
-_ libraries need to remove the PLibrary interface
-_ particles lib requires depth() (but shouldn't)
-_ fix for 78 since not sure when simon's new version is happening
-X should we queue lib events until the end of loop?
-_ nope, libraries can handle that themselves,
-_ and queue events by registering for draw or whatever they'd like
-_ lib could call queueEvent with the args
-_ then call them inside post()
_ add prompt() method to Serial (simple dialog box that pops up)
-_ get an xml library in there
-_ nanoxml problems with manifest
-_ appears to use 1.6.8 version since it's just two classes
_ subfolders in the 'data' directory don't work
_ don't allow goofy case versions of reserved words
_ keypressed should maybe throw an error
-_ "new midlet" option.. keeping things open for midlet projects
-
_ track loadImage() with filenames that are inconsistent
_ i.e. mixed case filename in sketch is different in windows
_ but when uploaded to a unix server causes a serious problem
@@ -170,11 +218,6 @@ _ images should be a power of 2, or call modified()
_ document the use of "die"
_ can override the method to do your own handling
_ sketches no longer require a "data" folder
-_ "draw" is not highlighted as a keyword.. other keywords?
-_ draw(), PGraphics(), NO_DEPTH_TEST, PMovie(), PMovie.repeat()
-_ PClient(), PClient.available(), PClient.read(),
-_ PServer(), PServer.dispose(), PServer.write(), attach(), length
-_ round() is not colored
_ example that uses loop/noLoop, or redraw?
_ talk to creas about making html files for bugs, readme, revisions.
_ or how they should relate to the 'faq'.. readme -> faq?
@@ -193,6 +236,9 @@ _ needs to be noted for the reference
_ make a note that u/v coordinates clamp at 0 and 1
_ no transformations before background() is called
_ implementation specific, may cause trouble
+_ get an xml library in there
+_ nanoxml problems with manifest
+_ appears to use 1.6.8 version since it's just two classes
_ different name for 'lib' folder because of libraries folder?
_ avoid some confusion for when describing the libraries folder to users
@@ -269,6 +315,10 @@ _ http://processing.org/discourse/yabb/YaBB.cgi?board=Proce55ing_Software;acti
_ applet default is one file, application default is multiple
_ user in advanced mode can switch to the other
_ buttons on side of sketch do default (last) behavior
+_ need to decide how to handle "stop" button in present mode
+_ when running externally, people need to write their own stop function
+_ just get export to application working so this can be supported
+_ for now, they're stuck w/ running in the env and getting the ugliness
@@ -282,8 +332,6 @@ PDE - Processing Development Environment
PDE / Details
1 _ preferences
- 1 _ make preferences a modal dialog
- 1 _ it's annoying when it hides itself
1 _ redo panel to use proper swing layout etc
1 _ setting sketchbook to a folder on the network
@@ -295,6 +343,8 @@ PDE / Details
1 _ save caret position when switching tabs
1 _ ctrl-tab to switch between tabs
+ 1 _ maintain tab scroll and caret positions
+
1 _ add mnemonics for menus (alt-f to open 'file')
1 _ processing.exe: problem if expert version is run, and no java installed