making a complete mess of preferences

This commit is contained in:
benfry
2003-11-05 20:54:30 +00:00
parent a9e7fa7059
commit 541e749b16
4 changed files with 558 additions and 466 deletions

View File

@@ -35,12 +35,6 @@ import javax.swing.event.*;
import javax.swing.text.*;
import javax.swing.undo.*;
#ifndef RXTX
import javax.comm.*;
#else
import gnu.io.*;
#endif
#ifdef MACOS
import com.apple.mrj.*;
#endif
@@ -58,9 +52,9 @@ public class PdeBase extends Frame
, MRJPrefsHandler
#endif
{
static final String VERSION = "0067 Alpha";
static final String VERSION = "0068 Alpha";
static Properties properties;
//static Properties properties;
static Properties keywords; // keyword -> reference html lookup
//static Frame frame; // now 'this'
@@ -92,12 +86,12 @@ public class PdeBase extends Frame
}
};
Menu serialMenu;
//Menu serialMenu;
MenuItem undoItem, redoItem;
MenuItem saveMenuItem;
MenuItem saveAsMenuItem;
MenuItem beautifyMenuItem;
CheckboxMenuItem externalEditorItem;
//CheckboxMenuItem externalEditorItem;
//Menu renderMenu;
CheckboxMenuItem normalItem, openglItem;
@@ -199,116 +193,7 @@ public class PdeBase extends Frame
//frame.addWindowListener(windowListener);
this.addWindowListener(windowListener);
properties = new Properties();
try {
//properties.load(new FileInputStream("lib/pde.properties"));
//#URL where = getClass().getResource("PdeBase.class");
//System.err.println(where);
//System.getProperties().list(System.err);
//System.err.println("userdir = " + System.getProperty("user.dir"));
if (PdeBase.platform == PdeBase.MACOSX) {
//String pkg = "Proce55ing.app/Contents/Resources/Java/";
//properties.load(new FileInputStream(pkg + "pde.properties"));
//properties.load(new FileInputStream(pkg + "pde.properties_macosx"));
properties.load(new FileInputStream("lib/pde.properties"));
properties.load(new FileInputStream("lib/pde_macosx.properties"));
} else if (PdeBase.platform == PdeBase.MACOS9) {
properties.load(new FileInputStream("lib/pde.properties"));
properties.load(new FileInputStream("lib/pde_macos9.properties"));
} else {
// under win95, current dir not set properly
// so using a relative url like "lib/" won't work
properties.load(getClass().getResource("pde.properties").openStream());
String platformProps = "pde_" + platforms[platform] + ".properties";
properties.load(getClass().getResource(platformProps).openStream());
}
//properties.list(System.out);
} catch (Exception e) {
System.err.println("Error reading pde.properties");
e.printStackTrace();
//System.exit(1);
}
// 0058 check to see if quicktime for java is installed on windows
// 0058 since it's temporarily required for 0058
// 0059 still required for 0059, since BApplet uses it when
// 0059 compiled with video enabled. the fix for this ain't easy.
if (platform == WINDOWS) {
//println(System.getenv("QTJAVA"));
//Process p = Runtime.getRuntime().exec("c:\\windows\\system32\\cmd.exe /C set");
/*
try {
Process p = Runtime.getRuntime().exec("cmd /C echo %QTJAVA%");
InputStream is = p.getInputStream();
StringBuffer sb = new StringBuffer();
int c;
while ((c = is.read()) != '\r') {
if (c == '\"') continue;
//println(c);
sb.append((char)c);
}
is.close();
println(">>" + sb.toString() + "<<");
} catch (IOException e) {
e.printStackTrace();
}
*/
// location for 95/98/ME/XP
//File qt1 = new File("C:\\WINDOWS\\system32\\QTJava.zip");
// location for win2k
//File qt2 = new File("C:\\WINNT\\system32\\QTJava.zip");
//if (!qt1.exists() && !qt2.exists()) {
//System.out.println("jcp = " + System.getProperty("java.class.path"));
try {
Class c = Class.forName("quicktime.std.StdQTConstants");
//System.out.println("class is " + c);
} catch (ClassNotFoundException e) {
e.printStackTrace();
final String message =
"QuickTime for Java could not be found.\n" +
"Please download QuickTime from Apple at:\n" +
"http://www.apple.com/quicktime/download\n" +
"and use the 'Custom' install to make sure\n" +
"that QuickTime for Java is included.\n" +
"If it's already installed, try reinstalling\n" +
"or read bugs.txt for other possible remedies.";
JOptionPane.showMessageDialog(this, message,
"Could not find QuickTime for Java",
JOptionPane.WARNING_MESSAGE);
System.exit(1); // can't run without quicktime
}
} else if (platform == MACOSX) {
try {
Class c = Class.forName("quicktime.std.StdQTConstants");
} catch (ClassNotFoundException e) {
e.printStackTrace();
final String message =
"Could not load QuickTime for Java. This probably means\n" +
"that you've installed QuickTime 6.4, in which Apple has\n" +
"neglected to include QuickTime for Java. More information\n" +
"and a (temporary) fix can be found in bugs.txt.";
JOptionPane.showMessageDialog(this, message,
"This headache's for you, big Steve",
JOptionPane.WARNING_MESSAGE);
System.exit(1); // can't run without quicktime
}
}
prefs = new PdePreferences();
// read in the keywords for the reference
@@ -525,8 +410,8 @@ public class PdeBase extends Frame
menu.addSeparator();
//menu.addSeparator();
serialMenu = new Menu("Serial Port");
menu.add(serialMenu);
//serialMenu = new Menu("Serial Port");
//menu.add(serialMenu);
Menu rendererMenu = new Menu("Renderer");
#ifdef OPENGL
@@ -553,6 +438,7 @@ public class PdeBase extends Frame
}
});
/*
externalEditorItem = new CheckboxMenuItem("Use External Editor");
externalEditorItem.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
@@ -565,6 +451,7 @@ public class PdeBase extends Frame
}
});
menu.add(externalEditorItem);
*/
menu.addActionListener(this);
menubar.add(menu); // add the sketch menu
@@ -600,34 +487,16 @@ public class PdeBase extends Frame
this.pack(); // maybe this should be before the setBounds call
//editor.frame = frame; // no longer really used
editor.init();
//editor.init();
// now that everything is set up, open last-used sketch, etc.
prefs.apply();
rebuildSketchbookMenu(sketchbookMenu);
buildSerialMenu();
//buildSerialMenu();
this.show(); // added back in for pde
}
/*
PdeEditorTextPane
Hashtable actions;
//The following two methods allow us to find an
//action provided by the editor kit by its name.
private void createActionTable(JTextComponent textComponent) {
actions = new Hashtable();
Action[] actionsArray = textComponent.getActions();
for (int i = 0; i < actionsArray.length; i++) {
Action a = actionsArray[i];
actions.put(a.getValue(Action.NAME), a);
}
}
private Action getActionByName(String name) {
//System.out.println(name);
//System.out.println(name + " " + actions);
return (Action)(actions.get(name));
}
*/
//This one listens for edits that can be undone.
protected class MyUndoableEditListener implements UndoableEditListener {
@@ -942,106 +811,6 @@ public class PdeBase extends Frame
}
class SerialMenuListener implements ItemListener /*, ActionListener*/ {
//public SerialMenuListener() { }
public void itemStateChanged(ItemEvent e) {
int count = serialMenu.getItemCount();
for (int i = 0; i < count; i++) {
((CheckboxMenuItem)serialMenu.getItem(i)).setState(false);
}
CheckboxMenuItem item = (CheckboxMenuItem)e.getSource();
item.setState(true);
String name = item.getLabel();
//System.out.println(item.getLabel());
PdeBase.properties.put("serial.port", name);
//System.out.println("set to " + get("serial.port"));
}
/*
public void actionPerformed(ActionEvent e) {
System.out.println(e.getSource());
String name = e.getActionCommand();
PdeBase.properties.put("serial.port", name);
System.out.println("set to " + get("serial.port"));
//editor.skOpen(path + File.separator + name, name);
// need to push "serial.port" into PdeBase.properties
}
*/
}
protected void buildSerialMenu() {
// get list of names for serial ports
// have the default port checked (if present)
SerialMenuListener listener = new SerialMenuListener();
String defaultName = get("serial.port", "unspecified");
boolean problem = false;
// if this is failing, it may be because
// lib/javax.comm.properties is missing.
// java is weird about how it searches for java.comm.properties
// so it tends to be very fragile. i.e. quotes in the CLASSPATH
// environment variable will hose things.
try {
//System.out.println("building port list");
Enumeration portList = CommPortIdentifier.getPortIdentifiers();
while (portList.hasMoreElements()) {
CommPortIdentifier portId =
(CommPortIdentifier) portList.nextElement();
//System.out.println(portId);
if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) {
//if (portId.getName().equals(port)) {
String name = portId.getName();
CheckboxMenuItem mi =
new CheckboxMenuItem(name, name.equals(defaultName));
//mi.addActionListener(listener);
mi.addItemListener(listener);
serialMenu.add(mi);
}
}
} catch (UnsatisfiedLinkError e) {
e.printStackTrace();
problem = true;
} catch (Exception e) {
System.out.println("exception building serial menu");
e.printStackTrace();
}
if (serialMenu.getItemCount() == 0) {
//System.out.println("dimming serial menu");
serialMenu.setEnabled(false);
}
// macosx fails on its own when trying to load the library
// so need to explicitly try here.. not sure if this is the
// correct lib, but it's at least one that's loaded inside
// the javacomm solaris stuff, which is the .jar that's included
// with the osx release (and rxtx takes over)
/*
if (platform == MACOSX) {
try {
System.loadLibrary("SolarisSerialParallel");
} catch (UnsatisfiedLinkError e) {
//e.printStackTrace();
problem = true;
}
}
*/
// only warn them if this is the first time
if (problem && firstTime) {
JOptionPane.showMessageDialog(this, //frame,
"Serial port support not installed.\n" +
"Check the readme for instructions\n" +
"if you need to use the serial port. ",
"Serial Port Warning",
JOptionPane.WARNING_MESSAGE);
}
}
// interfaces for MRJ Handlers, but naming is fine
// so used internally for everything else
@@ -1077,6 +846,8 @@ public class PdeBase extends Frame
}
public void handlePrefs() {
new PdePreferences();
/*
JOptionPane.showMessageDialog(this, //frame,
"Preferences are in the 'lib' folder\n" +
"inside text files named pde.properties\n" +
@@ -1084,6 +855,7 @@ public class PdeBase extends Frame
".properties",
"Preferences",
JOptionPane.INFORMATION_MESSAGE);
*/
//System.out.println("now showing preferences");
}
@@ -1412,74 +1184,4 @@ public class PdeBase extends Frame
} catch (InterruptedException e) { }
return image;
}
// this could be pruned further
// also a similar version inside PdeEditor
// (at least the binary portion)
/*
static public String getFile(String filename) {
if (filename.length() == 0) {
return null;
}
URL url;
InputStream stream = null;
String openMe;
byte temp[] = new byte[65536]; // 64k, 16k was too small
try {
// if running as an application, get file from disk
stream = new FileInputStream(filename);
} catch (Exception e1) { try {
url = this.getClass().getResource(filename);
stream = url.openStream();
} catch (Exception e2) { try {
// Try to open the param string as a URL
url = new URL(filename);
stream = url.openStream();
} catch (Exception e3) {
return null;
} } }
try {
int offset = 0;
while (true) {
int byteCount = stream.read(temp, offset, 1024);
if (byteCount <= 0) break;
offset += byteCount;
}
byte program[] = new byte[offset];
System.arraycopy(temp, 0, program, 0, offset);
//return languageEncode(program);
// convert the bytes based on the current encoding
try {
if (encoding == null)
return new String(program);
return new String(program, encoding);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
encoding = null;
return new String(program);
}
} catch (Exception e) {
System.err.println("problem during download");
e.printStackTrace();
return null;
}
}
*/
/*
static public boolean hasFullPrivileges() {
//if (applet == null) return true; // application
//return false;
return !isApplet();
}
*/
}

View File

@@ -277,101 +277,6 @@ public class PdeEditor extends JPanel {
}
public void init() {
// load the last program that was in use
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
int windowX = -1, windowY = 0, windowW = 0, windowH = 0;
Properties skprops = new Properties();
try {
if (PdeBase.platform == PdeBase.MACOSX) {
//String pkg = "Proce55ing.app/Contents/Resources/Java/";
//skprops.load(new FileInputStream(pkg + "sketch.properties"));
skprops.load(new FileInputStream("lib/sketch.properties"));
} else if (PdeBase.platform == PdeBase.MACOS9) {
skprops.load(new FileInputStream("lib/sketch.properties"));
} else {
skprops.load(getClass().getResource("sketch.properties").openStream());
}
windowX = Integer.parseInt(skprops.getProperty("window.x", "-1"));
windowY = Integer.parseInt(skprops.getProperty("window.y", "-1"));
windowW = Integer.parseInt(skprops.getProperty("window.w", "-1"));
windowH = Integer.parseInt(skprops.getProperty("window.h", "-1"));
// if screen size has changed, the window coordinates no longer
// make sense, so don't use them unless they're identical
int screenW = Integer.parseInt(skprops.getProperty("screen.w", "-1"));
int screenH = Integer.parseInt(skprops.getProperty("screen.h", "-1"));
if ((screen.width != screenW) || (screen.height != screenH)) {
// probably not valid for this machine, so invalidate sizing
windowX = -1;
}
String name = skprops.getProperty("sketch.name");
String path = skprops.getProperty("sketch.directory");
String user = skprops.getProperty("user.name");
String what = path + File.separator + name + ".pde";
if (windowX != -1) {
String dividerLocation =
skprops.getProperty("editor.divider.location");
if (dividerLocation != null) {
splitPane.setDividerLocation(Integer.parseInt(dividerLocation));
}
}
if (new File(what).exists()) {
userName = user;
skOpen(path, name);
} else {
userName = "default";
skNew();
}
String serialPort = skprops.getProperty("serial.port");
if (serialPort != null) {
PdeBase.properties.put("serial.port", serialPort);
}
boolean ee = new Boolean(skprops.getProperty("editor.external", "false")).booleanValue();
setExternalEditor(ee);
} catch (Exception e) {
// this exception doesn't matter, it's just the normal course of things
// the app reaches here when no sketch.properties file exists
//e.printStackTrace();
// indicator that this is the first time this feller has used p5
PdeBase.firstTime = true;
// even if folder for 'default' user doesn't exist, or
// sketchbook itself is missing, mkdirs() will make it happy
userName = "default";
// doesn't exist, not available, make my own
skNew();
}
if (windowX == -1) {
//System.out.println("using defaults for window size");
windowW = PdeBase.getInteger("window.width", 500);
windowH = PdeBase.getInteger("window.height", 500);
windowX = (screen.width - windowW) / 2;
windowY = (screen.height - windowH) / 2;
}
//PdeBase.frame.setBounds(windowX, windowY, windowW, windowH);
base.setBounds(windowX, windowY, windowW, windowH);
//rebuildSketchbookMenu(PdeBase.sketchbookMenu);
}
protected void changeText(String what, boolean emptyUndo) {
textarea.setText(what);
@@ -1896,7 +1801,7 @@ public class PdeEditor extends JPanel {
//System.out.println("setting ee to " + externalEditor);
textarea.setEditable(!external);
base.externalEditorItem.setState(external);
//base.externalEditorItem.setState(external);
base.saveMenuItem.setEnabled(!external);
base.saveAsMenuItem.setEnabled(!external);
base.beautifyMenuItem.setEnabled(!external);

461
app/PdePreferences.java Normal file
View File

@@ -0,0 +1,461 @@
/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
PdePreferences - controls user preferences
Part of the Processing project - http://Proce55ing.net
Copyright (c) 2001-03
Ben Fry, Massachusetts Institute of Technology and
Casey Reas, Interaction Design Institute Ivrea
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.net.*;
import java.util.*;
import java.util.zip.*;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.event.*;
import javax.swing.text.*;
import javax.swing.undo.*;
/*
#ifndef RXTX
import javax.comm.*;
#else
import gnu.io.*;
#endif
*/
/*
need to bring all the prefs into here
PdeEditor with its sketch.properties
and PdeBase with pde.properties
on first run:
processing.properties is created in user.home
it contains the contents of
pde.properties + pde_platform.properties
and then begins writing additional sketch.properties stuff
*/
public class PdePreferences extends JComponent {
// gui variables
static final int BIG = 13;
static final int BETWEEN = 13;
static final int SMALL = 6;
JFrame frame;
int wide, high;
JCheckBox newSketchPrompt;
JTextField sketchbookLocation;
// data model
Properties properties;
public PdePreferences() {
// load preferences
properties = new Properties();
try {
//properties.load(new FileInputStream("lib/pde.properties"));
//#URL where = getClass().getResource("PdeBase.class");
//System.err.println(where);
//System.getProperties().list(System.err);
//System.err.println("userdir = " + System.getProperty("user.dir"));
if (PdeBase.platform == PdeBase.MACOSX) {
//String pkg = "Proce55ing.app/Contents/Resources/Java/";
//properties.load(new FileInputStream(pkg + "pde.properties"));
//properties.load(new FileInputStream(pkg + "pde.properties_macosx"));
properties.load(new FileInputStream("lib/pde.properties"));
properties.load(new FileInputStream("lib/pde_macosx.properties"));
} else if (PdeBase.platform == PdeBase.MACOS9) {
properties.load(new FileInputStream("lib/pde.properties"));
properties.load(new FileInputStream("lib/pde_macos9.properties"));
} else {
// under win95, current dir not set properly
// so using a relative url like "lib/" won't work
properties.load(getClass().getResource("pde.properties").openStream());
String platformProps = "pde_" + platforms[platform] + ".properties";
properties.load(getClass().getResource(platformProps).openStream());
}
//properties.list(System.out);
} catch (Exception e) {
System.err.println("Error reading pde.properties");
e.printStackTrace();
//System.exit(1);
}
// setup frame for the prefs
frame = new JFrame("Preferences");
frame.setResizable(false);
Container pain = this;
//Container pain = frame.getContentPane();
pain.setLayout(null);
int top = BIG;
int left = BIG;
int right = 0;
JLabel label;
JButton button;
JComboBox combo;
Dimension d, d2, d3;
int h, v, vmax;
// [ ] Prompt for name and folder when creating new sketch
newSketchPrompt =
new JCheckBox("Prompt for name when creating a new sketch");
pain.add(newSketchPrompt);
d = newSketchPrompt.getPreferredSize();
newSketchPrompt.setBounds(left, top, d.width, d.height);
right = Math.max(right, left + d.width);
top += d.height + BETWEEN;
// Sketchbook location: [...............................] [ Browse ]
label = new JLabel("Sketchbook location:");
pain.add(label);
d = label.getPreferredSize();
sketchbookLocation = new JTextField(18);
pain.add(sketchbookLocation);
d2 = sketchbookLocation.getPreferredSize();
button = new JButton("Browse");
pain.add(button);
d3 = button.getPreferredSize();
// take max height of all components to vertically align em
vmax = Math.max(Math.max(d.height, d2.height), d3.height);
label.setBounds(left, top + (vmax-d.height)/2,
d.width, d.height);
h = left + d.width + BETWEEN;
sketchbookLocation.setBounds(h, top + (vmax-d2.height)/2,
d2.width, d2.height);
h += d2.width + BETWEEN;
button.setBounds(h, top + (vmax-d3.height)/2,
d3.width, d3.height);
right = Math.max(right, h + d3.width + BIG);
top += vmax + BETWEEN;
// Default serial port: [ COM1 + ]
/*
label = new JLabel("Default serial port:");
pain.add(label);
d = label.getPreferredSize();
Vector list = buildPortList();
combo = new JComboBox(list);
pain.add(combo);
d2 = combo.getPreferredSize();
if (list.size() == 0) {
label.setEnabled(false);
combo.setEnabled(false);
} else {
String defaultName = PdeBase.get("serial.port", "unspecified");
combo.setSelectedItem(defaultName);
}
vmax = Math.max(d.height, d2.height);
label.setBounds(left, top + (vmax-d.height)/2,
d.width, d.height);
h = left + d.width + BETWEEN;
combo.setBounds(h, top + (vmax-d2.height)/2,
d2.width, d2.height);
right = Math.max(right, h + d2.width + BIG);
top += vmax + BETWEEN;
*/
// [ ] Use external editor
//
String blather =
"More preferences are in the 'lib' folder inside text files\n" +
"named pde.properties and pde_" +
PdeBase.platforms[PdeBase.platform] + ".properties";
JTextArea textarea = new JTextArea(blather);
textarea.setBorder(new EmptyBorder(SMALL, SMALL, SMALL, SMALL));
textarea.setFont(new Font("Dialog", Font.PLAIN, 12));
pain.add(textarea);
//pain.add(label);
d = textarea.getPreferredSize();
textarea.setBounds(left, top, d.width, d.height);
top += d.height + BETWEEN;
//
wide = right + BIG;
high = top + BIG;
setSize(wide, high);
Container content = frame.getContentPane();
content.setLayout(new BorderLayout());
content.add(this, BorderLayout.CENTER);
frame.pack();
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
frame.setLocation((screen.width - wide) / 2,
(screen.height - high) / 2);
//
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
handleQuit();
}
});
//frame.show();
}
public void showFrame() {
frame.show();
}
// open the last-used sketch, etc
public void apply() {
}
public void init() {
// load the last program that was in use
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
int windowX = -1, windowY = 0, windowW = 0, windowH = 0;
Properties skprops = new Properties();
try {
if (PdeBase.platform == PdeBase.MACOSX) {
//String pkg = "Proce55ing.app/Contents/Resources/Java/";
//skprops.load(new FileInputStream(pkg + "sketch.properties"));
skprops.load(new FileInputStream("lib/sketch.properties"));
} else if (PdeBase.platform == PdeBase.MACOS9) {
skprops.load(new FileInputStream("lib/sketch.properties"));
} else {
skprops.load(getClass().getResource("sketch.properties").openStream());
}
windowX = Integer.parseInt(skprops.getProperty("window.x", "-1"));
windowY = Integer.parseInt(skprops.getProperty("window.y", "-1"));
windowW = Integer.parseInt(skprops.getProperty("window.w", "-1"));
windowH = Integer.parseInt(skprops.getProperty("window.h", "-1"));
// if screen size has changed, the window coordinates no longer
// make sense, so don't use them unless they're identical
int screenW = Integer.parseInt(skprops.getProperty("screen.w", "-1"));
int screenH = Integer.parseInt(skprops.getProperty("screen.h", "-1"));
if ((screen.width != screenW) || (screen.height != screenH)) {
// probably not valid for this machine, so invalidate sizing
windowX = -1;
}
String name = skprops.getProperty("sketch.name");
String path = skprops.getProperty("sketch.directory");
String user = skprops.getProperty("user.name");
String what = path + File.separator + name + ".pde";
if (windowX != -1) {
String dividerLocation =
skprops.getProperty("editor.divider.location");
if (dividerLocation != null) {
splitPane.setDividerLocation(Integer.parseInt(dividerLocation));
}
}
if (new File(what).exists()) {
userName = user;
skOpen(path, name);
} else {
userName = "default";
skNew();
}
String serialPort = skprops.getProperty("serial.port");
if (serialPort != null) {
PdeBase.properties.put("serial.port", serialPort);
}
boolean ee = new Boolean(skprops.getProperty("editor.external", "false")).booleanValue();
setExternalEditor(ee);
} catch (Exception e) {
// this exception doesn't matter, it's just the normal course of things
// the app reaches here when no sketch.properties file exists
//e.printStackTrace();
// indicator that this is the first time this feller has used p5
PdeBase.firstTime = true;
// even if folder for 'default' user doesn't exist, or
// sketchbook itself is missing, mkdirs() will make it happy
userName = "default";
// doesn't exist, not available, make my own
skNew();
}
if (windowX == -1) {
//System.out.println("using defaults for window size");
windowW = PdeBase.getInteger("window.width", 500);
windowH = PdeBase.getInteger("window.height", 500);
windowX = (screen.width - windowW) / 2;
windowY = (screen.height - windowH) / 2;
}
//PdeBase.frame.setBounds(windowX, windowY, windowW, windowH);
base.setBounds(windowX, windowY, windowW, windowH);
//rebuildSketchbookMenu(PdeBase.sketchbookMenu);
}
/*
externalEditorItem = new CheckboxMenuItem("Use External Editor");
externalEditorItem.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
//System.out.println(e);
if (e.getStateChange() == ItemEvent.SELECTED) {
editor.setExternalEditor(true);
} else {
editor.setExternalEditor(false);
}
}
});
menu.add(externalEditorItem);
*/
public Dimension getPreferredSize() {
return new Dimension(wide, high);
}
/*
class SerialMenuListener implements ItemListener {
//public SerialMenuListener() { }
public void itemStateChanged(ItemEvent e) {
int count = serialMenu.getItemCount();
for (int i = 0; i < count; i++) {
((CheckboxMenuItem)serialMenu.getItem(i)).setState(false);
}
CheckboxMenuItem item = (CheckboxMenuItem)e.getSource();
item.setState(true);
String name = item.getLabel();
//System.out.println(item.getLabel());
PdeBase.properties.put("serial.port", name);
//System.out.println("set to " + get("serial.port"));
}
}
*/
/*
protected Vector buildPortList() {
// get list of names for serial ports
// have the default port checked (if present)
Vector list = new Vector();
//SerialMenuListener listener = new SerialMenuListener();
boolean problem = false;
// if this is failing, it may be because
// lib/javax.comm.properties is missing.
// java is weird about how it searches for java.comm.properties
// so it tends to be very fragile. i.e. quotes in the CLASSPATH
// environment variable will hose things.
try {
//System.out.println("building port list");
Enumeration portList = CommPortIdentifier.getPortIdentifiers();
while (portList.hasMoreElements()) {
CommPortIdentifier portId =
(CommPortIdentifier) portList.nextElement();
//System.out.println(portId);
if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) {
//if (portId.getName().equals(port)) {
String name = portId.getName();
//CheckboxMenuItem mi =
//new CheckboxMenuItem(name, name.equals(defaultName));
//mi.addItemListener(listener);
//serialMenu.add(mi);
list.addElement(name);
}
}
} catch (UnsatisfiedLinkError e) {
e.printStackTrace();
problem = true;
} catch (Exception e) {
System.out.println("exception building serial menu");
e.printStackTrace();
}
//if (serialMenu.getItemCount() == 0) {
//System.out.println("dimming serial menu");
//serialMenu.setEnabled(false);
//}
// only warn them if this is the first time
if (problem && PdeBase.firstTime) {
JOptionPane.showMessageDialog(this, //frame,
"Serial port support not installed.\n" +
"Check the readme for instructions\n" +
"if you need to use the serial port. ",
"Serial Port Warning",
JOptionPane.WARNING_MESSAGE);
}
return list;
}
*/
}

132
todo.txt
View File

@@ -1,29 +1,94 @@
0068
X ifdef JDK14 around a piece of 1.4 specific window code
_ "add library" menu item and submenu
_ iterate through the 'library' folders
_ eliminate the requirement for a 'data' folder
_ fix code for changing the sketch folder
_ sketch.properties should go into user.home
_ otherwise moving sketch folder will kill it
bugsies
_ find/replace hangs when recapitalizing things
_ if last line of code is a comment with no CR after it,
_ an OutOfMemoryError ensues
_ http://proce55ing.net/discourse/yabb/YaBB.cgi?board=Proce55ing_software_bugs;action=display;num=1067717095
_ new html code for eolas patent case
_ move html to external file in the lib folder
_ jikes errors have no newlines because it's a buffered reader
_ and the newlines are removed when read
_ new sphere code from toxi
_ http://proce55ing.net/discourse/yabb/YaBB.cgi?board=Syntax;action=display;num=1067005325
sketchbook
bf _ if sketchbook.dir is set, makes new sketchbook folder
bf _ reads sketchbook properly from other folder
bf _ but creates a new folder for new sketches to go into
bf _ install sketchbook into another location on person's machine
bf _ use System.getProperty("user.home");
bf _ remove the 'default' for sketchbook
bf _ bring this up on bboard and get votes
bf _ win2k: my documents, macosx: ~/Documents,
bf _ macos9: hd:Users?, linux: ~/sketchbook
bf _ move examples to folder that goes w/ p5 app
bf _ set examples somehow read-only
dh 1 _ 'save as' from examples puts into examples dir.. :(
dh 1 _ make it default to the user's sketch dir
bf _ sketchbook.dir not properly read or written
dh b _ may need to start putting properties somewhere besides lib
dh b _ home directory (or preferences folder under macos9)
dh b _ put screenshots into sketch folder
dh b _ http://proce55ing.net/discourse/yabb/YaBB.cgi?board=Syntax;action=display;num=1046185738;start=0
lotsa video issues
_ things will freeze if winvdig not installed
_ http://proce55ing.net/discourse/yabb/YaBB.cgi?board=Proce55ing_software_bugs;action=display;num=1065185464
_ quicktime 6.4 update breaks p5 on the mac?
_ http://docs.info.apple.com/article.html?artnum=93414&sessionID=anonymous%7C26893096&kbhost=kbase.info.apple.com%3a80%2f
_ "Type quicktime.std.stdQTConstants was not found"
_ http://proce55ing.net/discourse/yabb/YaBB.cgi?board=Proce55ing_software_bugs;action=display;num=1066358763
_ http://docs.info.apple.com/article.html?artnum=120255
_ split classes to BVideo and BMovie ?
_ video hanging without a camera installed
_ just locks up after running examples, then does the 'can't delete' thing
_ http://proce55ing.net/discourse/yabb/YaBB.cgi?board=Proce55ing_software_bugs;action=display;num=1060313779
_ first row of video pixels are black
_ casey says it may only be his camera
_ video.pixels don't seem to have high bytes set
_ so fill(video.pixels[blah]) doesn't work
_ test against 'pixels' example
_ make BVideo subclass BImage
_ make sure the high bits are getting set as opaque
_ make grayscale image in p5
_ could be used in conjunction with alpha() to properly set alpha values
void toGrayscale() {
int col,lum;
for(int i=0; i<pixels.length; i++) {
col=pixels[i];
// luminance = 0.3*red + 0.59*green + 0.11*blue
// 0.3*256 = 76
// 0.59*256 = 151
// 0.11*256 = 28
lum = (76*(col>>16&0xff)+151*(col>>8&0xff)+28*(col&0xff))>>8;
pixels[i]=lum<<16 | lum<<8 | lum;
}
}
_ problems running external vm/vm is hanging
_ http://proce55ing.net/discourse/yabb/YaBB.cgi?board=Proce55ing_software_bugs;action=display;num=1067867520;start=0
_ http://proce55ing.net/discourse/yabb/YaBB.cgi?board=Proce55ing_software_bugs;action=display;num=1067643186
_ option to disable smoothing on font creator
_ create font doesn't support umlauts
_ fix up font code to generate unicode chars, at least for iso8859-1 charset
_ http://proce55ing.net/discourse/yabb/YaBB.cgi?board=Programs;action=display;num=1067596427
_ if last line of code is a comment with no CR after it,
_ an OutOfMemoryError ensues
_ http://proce55ing.net/discourse/yabb/YaBB.cgi?board=Proce55ing_software_bugs;action=display;num=1067717095
_ new html code for eolas patent case
_ move html to external file in the lib folder
_ jikes errors have no newlines because it's a buffered reader
_ and the newlines are removed when read
_ new sphere code from toxi
_ http://proce55ing.net/discourse/yabb/YaBB.cgi?board=Syntax;action=display;num=1067005325
_ some way to properly quit sketch when stopped
_ if people have other threads they've spawned, impossible to stop
_ http://proce55ing.net/discourse/yabb/YaBB.cgi?board=Syntax;action=display;num=1067383998
@@ -100,27 +165,6 @@ _ text(String.valueOf(i+1), left + i*20, top);
_ unexpected token "String"
lotsa video issues
_ quicktime 6.4 update breaks p5 on the mac?
_ http://docs.info.apple.com/article.html?artnum=93414&sessionID=anonymous%7C26893096&kbhost=kbase.info.apple.com%3a80%2f
_ "Type quicktime.std.stdQTConstants was not found"
_ http://proce55ing.net/discourse/yabb/YaBB.cgi?board=Proce55ing_software_bugs;action=display;num=1066358763
_ http://docs.info.apple.com/article.html?artnum=120255
_ split classes to BVideo and BMovie ?
_ things will freeze if winvdig not installed
_ http://proce55ing.net/discourse/yabb/YaBB.cgi?board=Proce55ing_software_bugs;action=display;num=1065185464
_ video hanging without a camera installed
_ just locks up after running examples, then does the 'can't delete' thing
_ http://proce55ing.net/discourse/yabb/YaBB.cgi?board=Proce55ing_software_bugs;action=display;num=1060313779
_ first row of video pixels are black
_ casey says it may only be his camera
_ video.pixels don't seem to have high bytes set
_ so fill(video.pixels[blah]) doesn't work
_ test against 'pixels' example
_ make BVideo subclass BImage
_ make sure the high bits are getting set as opaque
DEVELOPERS
_ try ariel's Thread.yield() suggestion
_ set default framerate of 24? 30? 2x that?
@@ -173,26 +217,6 @@ bf b _ META-INF/MANIFEST.MF contains just "Main-Class: ClassName"
bf b _ main sticking point will be serial/qtjava in exports
sketchbook
bf _ if sketchbook.dir is set, makes new sketchbook folder
bf _ reads sketchbook properly from other folder
bf _ but creates a new folder for new sketches to go into
bf _ install sketchbook into another location on person's machine
bf _ remove the 'default' for sketchbook
bf _ bring this up on bboard and get votes
bf _ win2k: my documents, macosx: ~/Documents,
bf _ macos9: hd:Users?, linux: ~/sketchbook
bf _ move examples to folder that goes w/ p5 app
bf _ set examples somehow read-only
dh 1 _ 'save as' from examples puts into examples dir.. :(
dh 1 _ make it default to the user's sketch dir
bf _ sketchbook.dir not properly read or written
dh b _ may need to start putting properties somewhere besides lib
dh b _ home directory (or preferences folder under macos9)
dh b _ put screenshots into sketch folder
dh b _ http://proce55ing.net/discourse/yabb/YaBB.cgi?board=Syntax;action=display;num=1046185738;start=0
history
_ history causing trouble - super slow with a huge sketch
_ could instead be gzipped and appended to history.dat