mirror of
https://github.com/processing/processing4.git
synced 2026-02-03 21:59:20 +01:00
menu work, add files to sketch, font builder
This commit is contained in:
@@ -403,6 +403,9 @@ public class PdeBase extends Frame
|
||||
});
|
||||
menu.add(item);
|
||||
|
||||
beautifyMenuItem = new MenuItem("Beautify", new MenuShortcut('B'));
|
||||
menu.add(beautifyMenuItem);
|
||||
|
||||
menu.addSeparator();
|
||||
|
||||
item = new MenuItem("Find...", new MenuShortcut('F'));
|
||||
@@ -456,10 +459,21 @@ public class PdeBase extends Frame
|
||||
menu.add(new MenuItem("Stop", new MenuShortcut('T')));
|
||||
menu.addSeparator();
|
||||
|
||||
menu.add(new MenuItem("Add data file..."));
|
||||
menu.add(new MenuItem("Create font..."));
|
||||
|
||||
if ((platform == WINDOWS) || (platform == MACOSX)) {
|
||||
// no way to do an 'open in file browser' on other platforms
|
||||
// since there isn't any sort of standard
|
||||
menu.add(new MenuItem("Show sketch folder"));
|
||||
}
|
||||
|
||||
recordingHistory = getBoolean("history.recording", true);
|
||||
if (recordingHistory) {
|
||||
historyMenu = new Menu("History");
|
||||
menu.add(historyMenu);
|
||||
|
||||
/*
|
||||
item = new MenuItem("Clear History");
|
||||
item.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
@@ -471,11 +485,10 @@ public class PdeBase extends Frame
|
||||
});
|
||||
menu.add(item);
|
||||
menu.addSeparator();
|
||||
*/
|
||||
}
|
||||
|
||||
beautifyMenuItem = new MenuItem("Beautify", new MenuShortcut('B'));
|
||||
//item.setEnabled(false);
|
||||
menu.add(beautifyMenuItem);
|
||||
menu.addSeparator();
|
||||
|
||||
//menu.addSeparator();
|
||||
serialMenu = new Menu("Serial Port");
|
||||
@@ -816,8 +829,21 @@ public class PdeBase extends Frame
|
||||
if (!recordingHistory) return;
|
||||
|
||||
menu.removeAll();
|
||||
|
||||
File hfile = new File(path);
|
||||
if (!hfile.exists()) return;
|
||||
if (!hfile.exists()) return; // no history yet
|
||||
|
||||
MenuItem item = new MenuItem("Clear History");
|
||||
item.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (!editor.historyFile.delete()) {
|
||||
System.err.println("couldn't erase history");
|
||||
}
|
||||
rebuildHistoryMenu(historyMenu, editor.historyFile.getPath());
|
||||
}
|
||||
});
|
||||
menu.add(item);
|
||||
menu.addSeparator();
|
||||
|
||||
try {
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(new GZIPInputStream(new FileInputStream(path))));
|
||||
@@ -1060,6 +1086,15 @@ public class PdeBase extends Frame
|
||||
} else if (command.equals("Beautify")) {
|
||||
editor.doBeautify();
|
||||
|
||||
} else if (command.equals("Add data file...")) {
|
||||
editor.addDataFile();
|
||||
|
||||
} else if (command.equals("Create font...")) {
|
||||
new PdeFontBuilder(editor.sketchDir);
|
||||
|
||||
} else if (command.equals("Show sketch folder")) {
|
||||
openFolder(editor.sketchDir);
|
||||
|
||||
} else if (command.equals("Help")) {
|
||||
openURL(System.getProperty("user.dir") +
|
||||
File.separator + "reference" +
|
||||
@@ -1152,6 +1187,29 @@ public class PdeBase extends Frame
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Implements the other cross-platform headache of opening
|
||||
* a folder in the machine's native file browser.
|
||||
*/
|
||||
public void openFolder(File file) {
|
||||
try {
|
||||
String folder = file.getCanonicalPath();
|
||||
|
||||
if (platform == WINDOWS) {
|
||||
Runtime.getRuntime().exec("cmd /c \"" + folder + "\"");
|
||||
|
||||
#ifdef MACOS
|
||||
} else if (platform == MACOSX) {
|
||||
com.apple.mrj.MRJFileUtils.openURL("file://" + folder);
|
||||
|
||||
#endif
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// all the information from pde.properties
|
||||
|
||||
static public String get(String attribute) {
|
||||
|
||||
@@ -394,6 +394,8 @@ public class PdeEditor extends JPanel {
|
||||
}
|
||||
|
||||
try {
|
||||
boolean noPreviousHistory = false;
|
||||
|
||||
ByteArrayOutputStream old = null;
|
||||
if (historyFile.exists()) {
|
||||
InputStream oldStream = new GZIPInputStream(new BufferedInputStream(new FileInputStream(historyFile)));
|
||||
@@ -406,6 +408,9 @@ public class PdeEditor extends JPanel {
|
||||
}
|
||||
//return out.toByteArray();
|
||||
oldStream.close();
|
||||
|
||||
} else {
|
||||
noPreviousHistory = true; // rebuild menu
|
||||
}
|
||||
|
||||
OutputStream historyStream =
|
||||
@@ -458,6 +463,11 @@ public class PdeEditor extends JPanel {
|
||||
historyWriter.flush();
|
||||
historyWriter.close();
|
||||
|
||||
if (noPreviousHistory) {
|
||||
// to get add the actual menu, to get the 'clear' item in there
|
||||
base.rebuildHistoryMenu(historyFile.getPath());
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -1734,6 +1744,33 @@ public class PdeEditor extends JPanel {
|
||||
}
|
||||
|
||||
|
||||
public void addDataFile() {
|
||||
// get a dialog, select a file to add to the sketch
|
||||
String prompt = "Select an image or other data file to copy to your sketch";
|
||||
FileDialog fd = new FileDialog(new Frame(), prompt, FileDialog.LOAD);
|
||||
//if (sketchFile != null) {
|
||||
//fd.setDirectory(sketchFile.getPath());
|
||||
//}
|
||||
fd.show();
|
||||
|
||||
String directory = fd.getDirectory();
|
||||
String filename = fd.getFile();
|
||||
if (filename == null) return;
|
||||
|
||||
// copy the file into the folder
|
||||
// if people don't want it to copy, they can do it by hand
|
||||
File sourceFile = new File(directory, filename);
|
||||
|
||||
File dataFolder = new File(sketchDir, "data");
|
||||
if (!dataFolder.exists()) dataFolder.mkdirs();
|
||||
|
||||
File destFile = new File(dataFolder, filename);
|
||||
//System.out.println("copying from " + sourceFile);
|
||||
//System.out.println("copying to " + destFile);
|
||||
copyFile(sourceFile, destFile);
|
||||
}
|
||||
|
||||
|
||||
// TODO iron out bugs with this code under
|
||||
// different platforms, especially macintosh
|
||||
public void highlightLine(int lnum) {
|
||||
@@ -1842,7 +1879,9 @@ public class PdeEditor extends JPanel {
|
||||
}
|
||||
to.flush();
|
||||
from.close(); // ??
|
||||
from = null;
|
||||
to.close(); // ??
|
||||
to = null;
|
||||
|
||||
#ifdef JDK13
|
||||
bfile.setLastModified(afile.lastModified()); // jdk13 required
|
||||
|
||||
149
app/PdeFontBuilder.java
Normal file
149
app/PdeFontBuilder.java
Normal file
@@ -0,0 +1,149 @@
|
||||
/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
||||
|
||||
/*
|
||||
PdeFontBuilder - gui interface to font creation heaven/hell
|
||||
Part of the Processing project - http://Proce55ing.net
|
||||
|
||||
Copyright (c) 2001-03 Massachusetts Institute of Technology
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.*;
|
||||
//import java.net.*;
|
||||
//import java.text.*;
|
||||
//import java.util.*;
|
||||
//import java.util.zip.*;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.*;
|
||||
|
||||
|
||||
public class PdeFontBuilder extends JFrame {
|
||||
File targetFolder;
|
||||
|
||||
//JComboBox fontSelector;
|
||||
JList fontSelector;
|
||||
JComboBox styleSelector;
|
||||
JTextField sizeSelector;
|
||||
|
||||
static final String styles[] = {
|
||||
"Plain", "Bold", "Italic", "Bold Italic"
|
||||
};
|
||||
|
||||
String fontName;
|
||||
|
||||
|
||||
// font.deriveFont(float size)
|
||||
|
||||
public PdeFontBuilder(File targetFolder) {
|
||||
super("Create Font");
|
||||
|
||||
this.targetFolder = targetFolder;
|
||||
|
||||
Container pain = getContentPane();
|
||||
pain.setLayout(new BoxLayout(pain, BoxLayout.Y_AXIS));
|
||||
|
||||
String labelText =
|
||||
"Use this tool to create bitmap fonts for your program.\n" +
|
||||
"Select a font and size, and click 'OK' to generate a font\n" +
|
||||
"and add it to the data folder of the current sketch.\n" +
|
||||
"The recommended size for 3D applications is 48 points.";
|
||||
|
||||
//JLabel label = new JLabel(labelText);
|
||||
JTextArea textarea = new JTextArea(labelText);
|
||||
textarea.setFont(new Font("Dialog", Font.PLAIN, 12));
|
||||
pain.add(textarea);
|
||||
//pain.add(label);
|
||||
|
||||
JPanel panel = new JPanel();
|
||||
//panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
|
||||
|
||||
GraphicsEnvironment ge =
|
||||
GraphicsEnvironment.getLocalGraphicsEnvironment();
|
||||
|
||||
Font fonts[] = ge.getAllFonts();
|
||||
String families[] = ge.getAvailableFontFamilyNames();
|
||||
|
||||
// don't care about families starting with . or #
|
||||
// also ignore dialog, dialoginput, monospaced, serif, sansserif
|
||||
|
||||
/*
|
||||
for (int i = 0; i < fonts.length; i++) {
|
||||
//System.out.println(fonts[i]);
|
||||
if (fonts[i].getFontName().indexOf(fonts[i].getFamily()) != 0) {
|
||||
System.out.println(fonts[i]);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
//fontSelector = new JComboBox();
|
||||
fontSelector = new JList(families);
|
||||
JScrollPane fontScroller = new JScrollPane(fontSelector);
|
||||
panel.add(fontScroller);
|
||||
//fontSelector.setFont(new Font("SansSerif", Font.PLAIN, 10));
|
||||
/*
|
||||
fontSelector.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
fontName = e.getActionCommand();
|
||||
}
|
||||
});
|
||||
*/
|
||||
//String list[] = Toolkit.getDefaultToolkit().getFontList();
|
||||
//for (int i = 0; i < list.length; i++) {
|
||||
/*
|
||||
for (int i = 0; i < families.length; i++) {
|
||||
//fontSelector.addItem(list[i]);
|
||||
fontSelector.addItem(families[i]);
|
||||
}
|
||||
panel.add(fontSelector);
|
||||
*/
|
||||
|
||||
styleSelector = new JComboBox();
|
||||
for (int i = 0; i < styles.length; i++) {
|
||||
styleSelector.addItem(styles[i]);
|
||||
}
|
||||
styleSelector.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
String command = e.getActionCommand();
|
||||
int style = Font.PLAIN;
|
||||
if (command.indexOf("Bold") != -1) {
|
||||
style |= Font.BOLD;
|
||||
}
|
||||
if (command.indexOf("Italic") != -1) {
|
||||
style |= Font.ITALIC;
|
||||
}
|
||||
}
|
||||
});
|
||||
panel.add(styleSelector);
|
||||
|
||||
sizeSelector = new JTextField("48");
|
||||
panel.add(sizeSelector);
|
||||
|
||||
pain.add(panel);
|
||||
|
||||
JPanel buttons = new JPanel();
|
||||
JButton cancelButton = new JButton("Cancel");
|
||||
JButton okButton = new JButton("OK");
|
||||
buttons.add(cancelButton);
|
||||
buttons.add(okButton);
|
||||
pain.add(buttons);
|
||||
|
||||
pack();
|
||||
show();
|
||||
}
|
||||
}
|
||||
@@ -103,14 +103,14 @@ cd /path/to/processing/build/linux
|
||||
|
||||
//// Updating to the Latest Version
|
||||
|
||||
1. Each time you want to update to latest version from cvs:
|
||||
5a. Each time you want to update to latest version from cvs:
|
||||
|
||||
cd /path/to/processing
|
||||
cvs -z3 update
|
||||
# -z3 means make it snappy (using compression)
|
||||
|
||||
|
||||
2. Or if new folders have been added, use:
|
||||
5b. Or if new folders have been added, use:
|
||||
|
||||
cd /path/to/processing
|
||||
cvs -z3 update -d -P
|
||||
@@ -127,9 +127,12 @@ cvs -z3 update -d -P
|
||||
# missing from a subfolder.
|
||||
|
||||
|
||||
3. If there have been significant changes, or you get weird build
|
||||
errors, try deleting (or renaming, if you need sketches from
|
||||
inside) your 'work' folder. This will create a fresh build.
|
||||
5c. If there have been significant changes, or you get weird build
|
||||
errors, try deleting (or renaming, if you need sketches from
|
||||
inside) your 'work' folder. This will create a fresh build.
|
||||
This includes any changes to the reference, the examples, the
|
||||
bagel serial libraries, jikes, or just about any time you
|
||||
have to use -d -P with the update.
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
@@ -305,4 +308,6 @@ cvs -z3 update -d -P
|
||||
If there have been significant changes, or you get weird build
|
||||
errors, try deleting (or renaming, if you need sketches from
|
||||
inside) your 'work' folder. This will create a fresh build.
|
||||
|
||||
This includes any changes to the reference, the examples, the
|
||||
bagel serial libraries, jikes, or just about any time you
|
||||
have to use -d -P with the update.
|
||||
|
||||
@@ -365,6 +365,34 @@ coding to be a lot more like sketching. the sketchbook and the
|
||||
. . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
||||
|
||||
|
||||
WHY JAVA? OR WHY SUCH A JAVA-ESQUE LANGUAGE?
|
||||
|
||||
|
||||
We didn't set out to make the ultimate language for visual
|
||||
programming, we set out to make something that was:
|
||||
|
||||
1) a sketchbook for our own work, simplifying the majority
|
||||
of tasks that we undertake,
|
||||
2) a teaching environment for that kind of process, and
|
||||
3) a point of transition to more complicated or difficult
|
||||
languages like full-blown Java or C++. (a gateway drug)
|
||||
|
||||
At the intersection of these points is a tradeoff between speed and
|
||||
simplicity of use. i.e. if we didnt' care about speed, python or other
|
||||
scripting languages would make far more sense. if we didn't care about
|
||||
transition to more advanced languages, we'd get rid of the crummy
|
||||
c-style (well, algol, really) syntax. etc etc.
|
||||
|
||||
Processing is not intended as the ultimate environment/language (in
|
||||
fact, the language is just Java, but with another graphics api and
|
||||
some simplifications), it's just putting together several years of
|
||||
experience in building things, and trying to simplify the parts that
|
||||
should be easier.
|
||||
|
||||
|
||||
. . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
||||
|
||||
|
||||
EXTERNAL FILES / FONTS / READING DATA FILES
|
||||
|
||||
|
||||
|
||||
18
todo.txt
18
todo.txt
@@ -4,17 +4,25 @@ X i.e. buzz.pl requires jdk13+ set for JDK13 flag, used by p5
|
||||
X usually need to remove the 'work' dir
|
||||
X modify macosx to use jikes from p5
|
||||
X in general, things are way simpler on the pc
|
||||
X move 'clear history' into the history menu itself
|
||||
X move beautify to the edit menu
|
||||
X menu item for copying data files to the sketch
|
||||
X "add files to sketch..." menu item
|
||||
|
||||
_ serious sluggishness with applets
|
||||
assigned to dan haskovec, completed by fry
|
||||
X event to explorer to open 'data' directory of project
|
||||
X better just to go directly to the sketch's folder
|
||||
X http://proce55ing.net/discourse/yabb/YaBB.cgi?board=Proce55ing_Software;action=display;num=1055926880
|
||||
|
||||
_ trying to track down sluggishness with applets..
|
||||
_ beginShape/endShape.. 3D scenes with boxes..
|
||||
|
||||
_ write script to remove .DS_Store and CVS folders from dist
|
||||
|
||||
|
||||
MEDIUM
|
||||
_ include version number in the about box
|
||||
_ http://proce55ing.net/discourse/yabb/YaBB.cgi?board=Proce55ing_software_bugs;action=display;num=1064220242
|
||||
_ adding files to sketch.. menu item
|
||||
_ also do drag & drop implementation to pull in files
|
||||
_ light(x, y, z, c1, c2, c3, TYPE)
|
||||
_ also BLight with same constructor, and on() and off() fxn
|
||||
_ better 1.3/1.4 support.. properly detect vm
|
||||
@@ -212,6 +220,7 @@ _ but couldn't remove the decoration from the window (jvm bug?)
|
||||
_ because it just quit without finishing
|
||||
_ macosx handleQuit forces termination (at least on 1.3)
|
||||
_ figure out how to prevent it, and add the 'cancel' button back
|
||||
_ drag & drop implementation to add files to sketch
|
||||
|
||||
|
||||
thesis / acg
|
||||
@@ -619,9 +628,6 @@ dh b _ could be a separate window that's always around if needed
|
||||
dh b _ shortcut to walk through history, ala photoshop (ctrl-alt-z)
|
||||
dh b _ external editor -> add a command to launch
|
||||
dh b _ http://proce55ing.net/discourse/yabb/YaBB.cgi?board=Proce55ing_Software;action=display;num=1043734580;start=0
|
||||
dh b _ event to explorer to open 'data' directory of project
|
||||
dh b _ better just to go directly to the sketch's folder
|
||||
dh b _ http://proce55ing.net/discourse/yabb/YaBB.cgi?board=Proce55ing_Software;action=display;num=1055926880
|
||||
|
||||
1 _ make a preference panel to set pde.properties stuff
|
||||
1 _ open button stays stuck if no sketch is selected from popup
|
||||
|
||||
Reference in New Issue
Block a user