tweaking on sketchbook.. frightening todo list

This commit is contained in:
benfry
2002-07-03 11:32:32 +00:00
parent 525c237264
commit 5f8891af7a
4 changed files with 196 additions and 127 deletions
+10 -5
View File
@@ -50,12 +50,13 @@ public class PdeBase implements ActionListener {
int width = getInteger("window.width", 600);
int height = getInteger("window.height", 350);
/*
encoding = get("encoding");
boolean beautify = false;
boolean convertSemicolons = false;
String program = get("program");
if (program != null) {
program = getFile(program);
//program = getFile(program);
} else {
program = get("inline_program");
convertSemicolons = true;
@@ -74,7 +75,9 @@ public class PdeBase implements ActionListener {
}
}
}
editor = new PdeEditor(/*this,*/ program);
*/
editor = new PdeEditor(/*this,*/ /*program*/);
frame.setLayout(new BorderLayout());
frame.add("Center", editor);
@@ -201,11 +204,11 @@ public class PdeBase implements ActionListener {
// header knows what the current user is
String userPath = sketchbookPath +
File.separator + editor.header.user;
File.separator + editor.userName;
File userFolder = new File(userPath);
if (!userFolder.exists()) {
System.err.println("sketchbook folder for '" + editor.header.user +
System.err.println("sketchbook folder for '" + editor.userName +
"' doesn't exist, creating a new one");
userFolder.mkdirs();
}
@@ -229,7 +232,7 @@ public class PdeBase implements ActionListener {
String toplevel[] = sketchbookFolder.list();
for (int i = 0; i < toplevel.length; i++) {
if ((toplevel[i].equals(editor.header.user)) ||
if ((toplevel[i].equals(editor.userName)) ||
(toplevel[i].equals(".")) ||
(toplevel[i].equals(".."))) continue;
@@ -406,6 +409,8 @@ public class PdeBase implements ActionListener {
// 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;
+58 -24
View File
@@ -27,6 +27,15 @@ public class PdeEditor extends Panel {
PdeEditorConsole console;
TextArea textarea;
// currently opened program
String userName; // user currently logged in
String sketchName; // name of the file (w/o pde if a sketch)
File sketchFile; // the .pde file itself
File sketchDir; // if a sketchbook project, the parent dir
//String lastDirectory;
//String lastFile;
PdeRunner runner;
Frame frame;
@@ -35,13 +44,10 @@ public class PdeEditor extends Panel {
static final int GRID_SIZE = 33;
static final int INSET_SIZE = 5;
String lastDirectory;
String lastFile;
boolean playing;
public PdeEditor(/*PdeBase app,*/ String program) {
public PdeEditor(/*PdeBase app,*/ /*String program*/) {
//this.app = app;
setLayout(new BorderLayout());
@@ -64,12 +70,15 @@ public class PdeEditor extends Panel {
Panel rightPanel = new Panel();
rightPanel.setLayout(new BorderLayout());
header = new PdeEditorHeader(this, "untitled", "default");
//header = new PdeEditorHeader(this, "untitled", "default");
//userName = "default";
header = new PdeEditorHeader(this /*, "", userName*/);
// need to open a file or hit new right away
rightPanel.add("North", header);
if (program == null) program = DEFAULT_PROGRAM;
//if (program == null) program = DEFAULT_PROGRAM;
textarea =
new TextArea(program,
new TextArea("", //program,
PdeBase.getInteger("editor.program.rows", 20),
PdeBase.getInteger("editor.program.columns", 60),
TextArea.SCROLLBARS_VERTICAL_ONLY);
@@ -96,6 +105,29 @@ public class PdeEditor extends Panel {
}
runner = new PdeRunner(this);
// load the last program that was in use
Properties skprops = new Properties();
try {
skprops.load(getClass().getResource("sketch.properties").openStream());
String sketch = (String) skprops.get("sketch.name");
String path = (String) skprops.get("sketch.directory");
String user = (String) skprops.get("user.name");
if (new File(path + File.separator + name +
File.separator + name + ".pde").exists()) {
userName = user;
skOpen(path, name);
} else {
skNew();
}
} catch (Exception e) {
// doesn't exist, not available, make my own
skNew();
}
}
@@ -216,22 +248,20 @@ public class PdeEditor extends Panel {
// does all the plumbing to create a new project
// then calls handleOpen to load it up
File sketchbookDir = new File("sketchbook", header.user);
File sketchbookDir = new File("sketchbook", userName); //header.user);
File sketchDir = null;
String sketchName = null;
System.out.println("1");
do {
int index = (int) (Math.random() * 1000);
sketchName = "sketch-" + pad3(index);
sketchDir = new File(sketchbookDir, sketchName);
} while (sketchDir.exists());
System.out.println("2");
// mkdir for new project name
sketchDir.mkdirs();
new File(sketchDir, "data").mkdirs();
new File(sketchDir, "build").mkdirs();
System.out.println("3");
// make empty pde file
File sketchFile = new File(sketchDir, sketchName + ".pde");
@@ -268,7 +298,8 @@ System.out.println("3");
public void skOpen(String path, String name) {
//header.isProject = true;
//header.project = name;
handleOpen(new File(path + File.separator + name, name + ".pde"),
handleOpen(name,
new File(path + File.separator + name, name + ".pde"),
new File(path));
}
@@ -277,8 +308,9 @@ System.out.println("3");
FileDialog fd = new FileDialog(new Frame(),
"Open a PDE program...",
FileDialog.LOAD);
fd.setDirectory(lastDirectory);
//fd.setFile(lastFile);
if (sketchFile != null) {
fd.setDirectory(sketchFile.getPath());
}
fd.show();
String directory = fd.getDirectory();
@@ -288,17 +320,14 @@ System.out.println("3");
return; // user cancelled
}
//header.isProject = false;
//header.project = filename;
handleOpen(new File(directory, filename), null);
handleOpen(filename, new File(directory, filename), null);
}
protected void handleOpen(File file, File projectDir) {
//File file = new File(directory, filename);
protected void handleOpen(String isketchName,
File isketchFile, File isketchDir) {
try {
FileInputStream input = new FileInputStream(file);
FileInputStream input = new FileInputStream(isketchFile);
int length = (int) file.length();
byte data[] = new byte[length];
@@ -308,8 +337,8 @@ System.out.println("3");
}
// set the last dir and file, so that they're
// the defaults when you try to save again
lastDirectory = file.getCanonicalPath(); //directory;
lastFile = file.getName(); //filename;
//lastDirectory = file.getCanonicalPath(); //directory;
//lastFile = file.getName(); //filename;
// once read all the bytes, convert it to the proper
// local encoding for this system.
@@ -320,7 +349,8 @@ System.out.println("3");
//else
//textarea.setText(new String(data, app.encoding));
header.setProject(file.getName(), projectDir);
//header.setProject(file.getName(), projectDir);
header.reset();
} catch (FileNotFoundException e1) {
e1.printStackTrace();
@@ -582,6 +612,10 @@ System.out.println("3");
public void doQuit() {
// write sketch.properties
URL url = getClass().getResource("sketch.properties");
System.out.println(url);
System.exit(0);
}
+43 -28
View File
@@ -13,7 +13,7 @@ import java.io.*;
*/
public class PdeEditorHeader extends Panel /* implements ActionListener*/ {
static final String PROJECT_TITLER = "sketch";
static final String SKETCH_TITLER = "sketch";
static final String USER_TITLER = "user";
//static final Color primaryColor = Color.white;
@@ -26,14 +26,13 @@ public class PdeEditorHeader extends Panel /* implements ActionListener*/ {
PdeEditor editor;
String project;
int projectLeft;
int projectRight;
int projectTitleLeft;
//boolean isProject;
File projectDir;
//private String sketch; // name of current file
int sketchLeft;
int sketchRight;
int sketchTitleLeft;
//File sketchDir;
String user;
//private String user;
int userLeft;
int userRight;
int userTitleLeft;
@@ -47,10 +46,10 @@ public class PdeEditorHeader extends Panel /* implements ActionListener*/ {
int imageW, imageH;
public PdeEditorHeader(PdeEditor editor, String project, String user) {
public PdeEditorHeader(PdeEditor editor /*, String sketch, String user*/) {
this.editor = editor;
this.project = project;
this.user = user;
//this.sketch = sketch;
//this.user = user;
if (primaryColor == null) {
backgroundColor = PdeBase.getColor("editor.header.bgcolor",
@@ -63,10 +62,17 @@ public class PdeEditorHeader extends Panel /* implements ActionListener*/ {
}
public void setProject(String project, File projectDir) {
this.project = project;
this.projectDir = projectDir;
projectLeft = 0;
public void reset() {
sketchLeft = 0;
userLeft = 0;
update();
}
/*
public void setSketch(String sketch, File sketchDir) {
this.sketch = sketch;
this.sketchDir = sketchDir;
sketchLeft = 0;
update();
}
@@ -74,6 +80,7 @@ public class PdeEditorHeader extends Panel /* implements ActionListener*/ {
this.user = user;
userLeft = 0;
}
*/
public void update() {
@@ -122,17 +129,23 @@ public class PdeEditorHeader extends Panel /* implements ActionListener*/ {
fontAscent = metrics.getAscent();
}
if (projectLeft == 0) {
projectTitleLeft = PdeEditor.INSET_SIZE;
projectLeft = projectTitleLeft +
metrics.stringWidth(PROJECT_TITLER) + PdeEditor.INSET_SIZE;
}
//if (sketchLeft == 0) {
sketchTitleLeft = PdeEditor.INSET_SIZE;
sketchLeft = sketchTitleLeft +
metrics.stringWidth(SKETCH_TITLER) + PdeEditor.INSET_SIZE;
if (userLeft == 0) {
userLeft = sizeW - 20 - metrics.stringWidth(user);
userTitleLeft = userLeft - PdeEditor.INSET_SIZE -
metrics.stringWidth(USER_TITLER);
}
//sketch = editor.sketchName;
//if (sketch == null) sketch = "";
//}
//if (userLeft == 0) {
userLeft = sizeW - 20 - metrics.stringWidth(editor.userName);
userTitleLeft = userLeft - PdeEditor.INSET_SIZE -
metrics.stringWidth(USER_TITLER);
//user = editor.userName;
//if (user == null) user = "";
//}
int baseline = (sizeH + fontAscent) / 2;
@@ -142,12 +155,14 @@ public class PdeEditorHeader extends Panel /* implements ActionListener*/ {
boolean boringUser = user.equals("default");
g.setColor(secondaryColor);
g.drawString(PROJECT_TITLER, projectTitleLeft, baseline);
g.drawString(SKETCH_TITLER, sketchTitleLeft, baseline);
if (!boringUser) g.drawString(USER_TITLER, userTitleLeft, baseline);
g.setColor(primaryColor);
g.drawString(project, projectLeft, baseline);
if (!boringUser) g.drawString(user, userLeft, baseline);
//g.drawString(sketch, sketchLeft, baseline);
g.drawString(editor.sketchName, sketchLeft, baseline);
//if (!boringUser) g.drawString(user, userLeft, baseline);
if (!boringUser) g.drawString(editor.userName, userLeft, baseline);
//g.setColor(fgColor[mode]);
//g.drawString(message, PdeEditor.INSET_SIZE, (sizeH + fontAscent) / 2);
+85 -70
View File
@@ -1,4 +1,6 @@
0031
X lib/pde.properties should be read using getResource
X otherwise path issues cause trouble (likely under win98)
in the morning
_ take state information out of Header
@@ -8,11 +10,7 @@ _ sketch: sketch-000 is dumb
_ make sure compiling into build directory
_ implement popup menu
_ save (just) last program run in sketch.properties
_ background(), fill(), stroke() using color datatype
_ check 0xff high bits to see if it's an int gray value or a color
_ fix curve()/bezier()
_ also make curve() work as 6 point with doubled endpoints
_ move structure of app/application dirs around a bit
pdebase simple
_ remove 'encoding' crap from PdeBase
@@ -22,15 +20,24 @@ _ better readFile/loadImage inside PdeBase
_ temp array should be resizable inside readFile
_ use getresource for loading image
play
a _ add frame to launched window
a X add maximize event catcher to make fullscreen
a o doesn't work, because of screen sizing stupidity
a _ shift-click on play to go directly into this 'presentation mode'
a _ make all windows 120x120?
a _ default program should be large, 300x200 or so
a _ what if it's smaller? boundary of color 51, 51, 51 around it
bagel-related
_ background(), fill(), stroke() using color datatype
_ check 0xff high bits to see if it's an int gray value or a color
_ fix curve()/bezier()
_ also make curve() work as 6 point with doubled endpoints
_ noClear -- implement with noBackground
_ need to set bg color even if updated
_ update/noUpdate() could also be done to force explicit updates only
_ make all windows 120x120?
_ default program should be large, 300x200 or so
_ what if it's smaller? boundary of color 51, 51, 51 around it
_ beautify is slightly broken
_ need to update PdeKeyListener for new ui..
_ remove open, add d for duplicate, r for rename, others ?
_ for ui-type applications that don't need to continually redraw
ui
a _ 'open' button is a switch-to button
@@ -50,6 +57,17 @@ a _ saves screen size, so if screen size changed, window pos reset
a _ if it doesn't exist, starts with a new project
a _ for a new project, name it untitled-0001 or as appropriate
a _ so that previous projects aren't written over
a _ need to update PdeKeyListener for new ui..
a _ remove open, add d for duplicate, r for rename, others ?
a _ verify save when
a _ closing p5 window
a _ moving to other sketch
_ project name is changed by clicking on the name and typing
_ user name is changed by clicking and typing
_ after user hits 'enter', checks to see if user exists
_ if not, pops up message asking if they want to change
_ message goes in same spot as error/status label (turns yellow?)
_ if user says 'no', then
users
a _ if default user, don't show the 'user' string in pde window
@@ -57,32 +75,6 @@ a _ item in pde.properties to set the name of the current user
_ menu option to change username/login
_ if new user, offer to rename 'default' if it contains things
file structure for export
a _ exporting to applet/.jar file
a _ need to set project name for files
a _ include other .class files built besides the main one
a _ compile into 'classes' folder
a _ include referenced image and font files (can't do if numbered)
included files
a _ 'data' directory for all media
a _ make included media part of the .jar file
a _ it's really a pain to use external files in processing
a _ getStream sucks (zach rewrote)
a _ should be able to work for application or applets
a _ may want to use getResource() (to get things from .jar files)
compiling
a _ remove .java and .class files for compiled classes
a _ (just clean up the boogers afterwards)
a _ compiling .java files leaves the .class files next to the .java
a _ make sure all the dirs in sketchbook added to classpath on startup
a _ if new dir added, must restart processing (this is acceptable)
running
a _ ability to include other code from sketchbook directory
a _ compile entire sketchbook on startup, check for new files on compile?
export
a _ exporting applets that have custom name problems:
a _ if extends processingapplet, the name user types must be same
@@ -97,11 +89,49 @@ a _ if extends ProcessingApplet [more compatible]
a _ make sure export is compiling first
a _ right now have to hit play and then hit export (?)
a _ include main class info for executable jar file with jdk > 1.2
a _ file structure for export
a _ need to set project name for files
a _ include other .class files built besides the main one
a _ compile into 'classes' folder
a _ include referenced image and font files (can't do if numbered)
a _ difference between exporting an applet and an application
a _ application can still do serial (qt, other stuff?)
a _ applet runs in browser, though applet on cbagel is everything..
a _ verify save when
a _ closing p5 window
a _ moving to other sketch
included files
a _ 'data' directory for all media
a _ make included media part of the .jar file
a _ it's really a pain to use external files in processing
a _ getStream sucks (zach rewrote)
a _ should be able to work for application or applets
a _ may want to use getResource() (to get things from .jar files)
compiling
a _ remove .java and .class files for compiled classes
a _ (just clean up the boogers afterwards)
a _ compiling .java files leaves the .class files next to the .java
a _ make sure all the dirs in sketchbook added to classpath on startup
a _ if new dir added, must restart processing (this is acceptable)
a _ kjc is really frustrating about some of its error/warning msgs
a _ erroneous errors from kjc regarding 'var not inited'
a _ is there any way to disable this message?
a _ talk to simon about error streams and kjc
a _ better piping of output from kjc
a _ modify kjc to take a PrintWriter, instead of current hacks
a _ might be able to set default values for vars using perl5subst
running
a _ ability to include other code from sketchbook directory
a _ compile entire sketchbook on startup, check for new files on compile?
is this true?
a _ lines being highlighted for errors are off
a _ test this on other platforms as well
a _ importing images doesn't work (?)
a _ Compiler.disable() message is weird and doesn't always work
a _ probably just remove it for now
other mess
_ modify to allow for the 'build' directory in lib
_ make a new 'dist' function for building
_ exceptions in draw() apps aren't caught
@@ -145,12 +175,6 @@ _ check out flash for its text editor
_ write function to swap different names for Proce55ing
_ use for window title
_ simple app that does swapping of letters as an animation
_ project name is changed by clicking on the name and typing
_ user name is changed by clicking and typing
_ after user hits 'enter', checks to see if user exists
_ if not, pops up message asking if they want to change
_ message goes in same spot as error/status label (turns yellow?)
_ if user says 'no', then
BUILDING P5
@@ -293,8 +317,13 @@ _ but how to determine *where* on object the hit occurs?
BAGEL / lower
_ support for moving the camera around
_ try using jgl inside processing
_ illustrator, postscript or pdf export?
_ export to static flash-based graphics
_ function to evaluate bezier or catmullrom points
_ used heavily in genome valence
_ curveMode to tweak the s parameter of catmullrom
_ why is every other pixel missing from mouse events?
_ fixed fonts are screwed, should only work at screen resolution
_ getStream for the filename doesn't work for directories
@@ -333,26 +362,6 @@ _ live video editing, wanting things more procedural
PDE / high
a _ add frame to launched window
a X add maximize event catcher to make fullscreen
a o doesn't work, because of screen sizing stupidity
a _ shift-click on play to go directly into this 'presentation mode'
a _ lines being highlighted for errors are off
a _ test this on other platforms as well
a _ importing images doesn't work
a _ Compiler.disable() message is weird and doesn't always work
a _ probably just remove it for now
a _ kjc is really frustrating about some of its error/warning msgs
a _ erroneous errors from kjc regarding 'var not inited'
a _ is there any way to disable this message?
a _ talk to simon about error streams and kjc
a _ better piping of output from kjc
a _ modify kjc to take a PrintWriter, instead of current hacks
a _ might be able to set default values for vars using perl5subst
a _ lib/pde.properties should be read using getResource
a _ otherwise path issues cause trouble (likely under win98)
a _ check logs to see where we're getting traffic from
b _ serial.messageReceived extra long crap in demo.pde (clean up?)
b _ improve simpleserial and clean up a bit
b _ document a bit more regarding its use
@@ -375,9 +384,9 @@ b _ or figure out how to unload old classes.. grr
PDE / medium
b _ include stdout/stderr in the processing window
b _ option to toggle window on/off (not just in properties, but realtime)
b _ set # of lines in properties
b _ check logs to see where we're getting traffic from
b _ event to explorer to open 'parts' directory of project
b _ option to toggle console on/off (not just in properties, but realtime)
b _ work on editor buttons
b _ play button not really working
b _ never un-highlights, especially with exceptions
@@ -393,6 +402,12 @@ b _ write code to bind/convert java fonts
b _ best would be freetype or jdk 1.3/1.4
b _ java freetype? jni freetype to build texmap fonts?
b _ look at flash file format? (does it have kerning?)
b _ example: multi-user server app (shared whiteboard)
b _ example: basic network app
b _ work out getStream
b _ file i/o utility classes
b _ read as set of lines, read as cells in grid, read num sequence
b _ then methods for writing all of the same
PDE / macos
@@ -408,7 +423,7 @@ a _ if os9, this is a no-brainer.. for osx may take a little time
PDE / low
_ support for moving the camera around
_ beautify is slightly broken
_ if 'void' left out before loop or setup, cryptic message about
_ 'constructor loop must be named Temporary_23498_2343'
_ add a better handler for this specific thing?