getting gl4java wired in, removing KjcApplet for simplicity

This commit is contained in:
benfry
2003-07-13 18:08:53 +00:00
parent fbb475c0e3
commit 4558cd64b7
11 changed files with 160 additions and 266 deletions

View File

@@ -1,6 +1,7 @@
// special subclass only used inside the pde environment
// while the kjc engine is in use. takes care of error handling.
#ifdef KJCAPPLET
public class KjcApplet extends BApplet {
PdeRuntime pdeRuntime;
@@ -21,6 +22,7 @@ public class KjcApplet extends BApplet {
}
}
}
#endif
/*

View File

@@ -50,7 +50,13 @@ public class PdeBase extends Frame implements ActionListener {
MenuItem beautifyMenuItem;
CheckboxMenuItem externalEditorItem;
static final String WINDOW_TITLE = "Proce55ing";
//Menu renderMenu;
CheckboxMenuItem normalItem, openglItem;
//MenuItem illustratorItem;
static final String WINDOW_TITLE = "Processing";
// the platforms
static final int WINDOWS = 1;
@@ -300,63 +306,8 @@ public class PdeBase extends Frame implements ActionListener {
});
menu.add(item);
/*
item = new MenuItem("Cut", new MenuShortcut('X'));
//Action act = getActionByName(DefaultEditorKit.cutAction);
//System.out.println("act is " + act);
item.addActionListener(getActionByName(DefaultEditorKit.cutAction));
menu.add(item);
item = new MenuItem("Copy", new MenuShortcut('C'));
item.addActionListener(getActionByName(DefaultEditorKit.copyAction));
menu.add(item);
item = new MenuItem("Paste", new MenuShortcut('V'));
item.addActionListener(getActionByName(DefaultEditorKit.pasteAction));
menu.add(item);
menu.addSeparator();
item = new MenuItem("Select All", new MenuShortcut('A'));
item.addActionListener(getActionByName(DefaultEditorKit.selectAllAction));
menu.add(item);
*/
menubar.add(menu);
/*
PdeEditorTextPane version
createActionTable(editor.textarea);
menu = new Menu("Edit");
//undoAction = new UndoAction();
//menu.add(undoAction);
item = new MenuItem("Undo", new MenuShortcut('Z'));
item.addActionListener(undoAction = new UndoAction());
menu.add(item);
item = new MenuItem("Redo", new MenuShortcut('Y'));
item.addActionListener(redoAction = new RedoAction());
menu.add(item);
menu.addSeparator();
item = new MenuItem("Cut", new MenuShortcut('X'));
//Action act = getActionByName(DefaultEditorKit.cutAction);
//System.out.println("act is " + act);
item.addActionListener(getActionByName(DefaultEditorKit.cutAction));
menu.add(item);
item = new MenuItem("Copy", new MenuShortcut('C'));
item.addActionListener(getActionByName(DefaultEditorKit.copyAction));
menu.add(item);
item = new MenuItem("Paste", new MenuShortcut('V'));
item.addActionListener(getActionByName(DefaultEditorKit.pasteAction));
menu.add(item);
menu.addSeparator();
item = new MenuItem("Select All", new MenuShortcut('A'));
item.addActionListener(getActionByName(DefaultEditorKit.selectAllAction));
menu.add(item);
menubar.add(menu);
// i hear a cs prof or a first year student screaming somewhere
//Document document = editor.textarea.document;
Document document = editor.textarea.getDocument();
document.addUndoableEditListener(new MyUndoableEditListener());
*/
Document document = editor.textarea.getDocument();
document.addUndoableEditListener(new MyUndoableEditListener());
@@ -391,6 +342,27 @@ public class PdeBase extends Frame implements ActionListener {
serialMenu = new Menu("Serial Port");
menu.add(serialMenu);
Menu rendererMenu = new Menu("Renderer");
menu.add(rendererMenu);
normalItem = new CheckboxMenuItem("Normal");
rendererMenu.add(normalItem);
normalItem.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
openglItem.setState(false);
normalItem.setState(true);
}
});
openglItem = new CheckboxMenuItem("OpenGL");
rendererMenu.add(openglItem);
openglItem.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
openglItem.setState(true);
normalItem.setState(false);
}
});
externalEditorItem = new CheckboxMenuItem("Use External Editor");
externalEditorItem.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {

View File

@@ -117,86 +117,30 @@ public class PdeEditor extends Panel {
add("West", leftPanel);
//Panel rightPanel = new Panel();
Panel rightPanel = new Panel();
//rightPanel.setLayout(new BorderLayout());
rightPanel.setLayout(new BoxLayout(rightPanel, BoxLayout.Y_AXIS));
header = new PdeEditorHeader(this);
rightPanel.add("North", header);
//textarea = new PdeEditorTextPane();
textarea = new JEditTextArea();
//textarea.setTokenMarker(new JavaTokenMarker());
textarea.setTokenMarker(new PdeTokenMarker());
/* PREVIOUS.. uses PdeEditorTextPane
JScrollPane scroller = new JScrollPane();
//scroller.setDoubleBuffered(true);
JViewport viewport = scroller.getViewport();
viewport.setDoubleBuffered(true);
//textarea = new JEditorPane("text/java", "");
viewport.add(textarea);
// viewport.setScrollMode(JViewport.BLIT_SCROLL_MODE);
// hack to set the font using the style, at least until i
// can figure out something better to do with styles/coloring
textarea.setFont(PdeBase.getFont("editor.program.default.style",
new Font("Monospaced",
Font.PLAIN, 12)));
*/
/*
// doesn't work
String farbe = PdeBase.get("editor.program.default.style");
farbe = farbe.substring(farbe.indexOf("#") + 1, farbe.lastIndexOf(","));
try {
int v = Integer.parseInt(farbe, 16);
textarea.setBackground(new Color(v));
System.out.println(new Color(v));
} catch (Exception e) {
e.printStackTrace();
} // oh well
*/
/*
textarea.setFont(PdeBase.getFont("editor.program.font",
new Font("Monospaced",
Font.PLAIN, 12)));
textarea.setForeground(PdeBase.getColor("editor.program.fgcolor",
Color.black));
*/
/* PREVIOUS.. uses PdeEditorTextPane
textarea.setBackground(PdeBase.getColor("editor.program.bgcolor",
Color.white));
rightPanel.add("Center", scroller);
*/
rightPanel.add("Center", textarea);
Panel statusPanel = new Panel();
//statusPanel.setLayout(new BorderLayout());
statusPanel.setLayout(new BoxLayout(statusPanel, BoxLayout.Y_AXIS));
///statusPanel.setLayout(new BorderLayout());
//statusPanel.setLayout(new FlowLayout(FlowLayout.VERTICAL));
status = new PdeEditorStatus(this);
statusPanel.add("Center", status);
///statusPanel.add(BorderLayout.NORTH, status);
console = new PdeEditorConsole(this);
statusPanel.add("South", console);
///statusPanel.add(BorderLayout.NORTH, console);
rightPanel.add("South", statusPanel);
//statusPanel.setMaximumSize(new Dimension(300, 50));
/* not sure why this doesn't work, probably a heavy vs. lightweight component issue
/* not sure why this doesn't work, probably a heavy vs. lightweight component issue
Panel consolePanel = new Panel();
consolePanel.setLayout(new BoxLayout(consolePanel, BoxLayout.Y_AXIS));
@@ -218,98 +162,12 @@ public class PdeEditor extends Panel {
bottom.setMinimumSize(minimumSize);
*/
/*
//pain = statusPanel;
textarea.addComponentListener(new ComponentAdapter() {
public void componentResized(ComponentEvent e) {
//System.out.println("textarea: " + e);
System.out.println("attempting to force layout");
//PdeBase.frame.doLayout();
pain.doLayout();
}
});
*/
add("Center", rightPanel);
// hopefully these are no longer needed w/ swing
// (that was wishful thinking, they still are, until we switch to jedit)
PdeEditorListener listener = new PdeEditorListener(this, textarea);
textarea.pdeEditorListener = listener;
//textarea.addKeyListener(listener);
//textarea.addFocusListener(listener);
/*
textarea.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent event) {
// don't do things if the textarea isn't editable
if (externalEditor) return;
// only works with TextArea, because it needs 'insert'
//tc = (TextArea) event.getSource();
//deselect();
char c = event.getKeyChar();
int code = event.getKeyCode();
//System.out.println(event);
if (!sketchModified) {
if ((code == KeyEvent.VK_BACK_SPACE) ||
(code == KeyEvent.VK_TAB) ||
(code == KeyEvent.VK_ENTER) ||
((c >= 32) && (c < 128))) {
setSketchModified(true);
}
}
case 9: // expand tabs
if (expandTabs) {
//System.out.println("start = " + tc.getSelectionStart());
//System.out.println("end = " + tc.getSelectionEnd());
//System.out.println("pos = " + tc.getCaretPosition());
tc.replaceRange(tabString, tc.getSelectionStart(),
tc.getSelectionEnd());
event.consume();
}
break;
case 10: // auto-indent
case 13:
if (autoIndent) {
//System.err.println("auto indenting");
char contents[] = tc.getText().toCharArray();
// back up until \r \r\n or \n.. @#($* cross platform
//index = contents.length-1;
int index = tc.getCaretPosition() - 1;
int spaceCount = 0;
boolean finished = false;
while ((index != -1) && (!finished)) {
if ((contents[index] == '\r') ||
(contents[index] == '\n')) {
finished = true;
} else {
spaceCount = (contents[index] == ' ') ?
(spaceCount + 1) : 0;
}
index--;
}
// !@#$@#$ MS VM doesn't move the caret position to the
// end of an insertion after it happens, even though sun does
String insertion = newline + spaces.substring(0, spaceCount);
int oldCarrot = tc.getSelectionStart();
tc.replaceRange(insertion, oldCarrot, tc.getSelectionEnd());
// microsoft vm version:
//tc.setCaretPosition(oldCarrot + insertion.length() - 1);
// sun vm version:
tc.setCaretPosition(oldCarrot + insertion.length());
event.consume();
}
break;
}
});
*/
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
if ((PdeBase.platform == PdeBase.MACOSX) ||
@@ -785,7 +643,9 @@ afterwards, some of these steps need a cleanup function
//
PdePreprocessor preprocessorOro =
new PdePreprocessorOro(program, buildPath);
className = preprocessorOro.writeJava(className, true);
className = preprocessorOro.writeJava(className,
base.normalItem.getState(),
false);
// compile the program
//
@@ -1507,10 +1367,11 @@ afterwards, some of these steps need a cleanup function
//
PdePreprocessor preprocessorOro =
new PdePreprocessorOro(program, appletDir.getPath());
exportSketchName = preprocessorOro.writeJava(exportSketchName, false);
PdeCompiler compilerKjc = new PdeCompilerKjc(appletDir.getPath(),
exportSketchName, this);
exportSketchName =
preprocessorOro.writeJava(exportSketchName,
base.normalItem.getState(), true);
PdeCompiler compilerKjc =
new PdeCompilerKjc(appletDir.getPath(), exportSketchName, this);
// this will catch and parse errors during compilation
messageStream = new PdeMessageStream(this, compilerKjc);

View File

@@ -28,8 +28,8 @@ public class PdeEditorConsole extends JScrollPane {
boolean cerror;
static final int HINSET = 6;
static final int VINSET = 6;
//static final int HINSET = 6;
//static final int VINSET = 6;
static PrintStream systemOut;
static PrintStream systemErr;
@@ -47,7 +47,7 @@ public class PdeEditorConsole extends JScrollPane {
JTextPane consoleTextPane = new JTextPane();
consoleTextPane.setEditable(false);
consoleDoc = consoleTextPane.getStyledDocument();
// necessary?
MutableAttributeSet standard = new SimpleAttributeSet();
StyleConstants.setAlignment(standard, StyleConstants.ALIGN_LEFT);
@@ -62,7 +62,7 @@ public class PdeEditorConsole extends JScrollPane {
new Color(204, 51, 0));
Font font = PdeBase.getFont("editor.console.font",
new Font("Monospaced", Font.PLAIN, 11));
stdStyle = new SimpleAttributeSet();
StyleConstants.setForeground(stdStyle, fgColorOut);
StyleConstants.setBackground(stdStyle, bgColor);

View File

@@ -2,10 +2,11 @@
//
public class PdePreprocessor {
public PdePreprocessor() {
}
public PdePreprocessor() {
}
public String writeJava(String name, boolean kjc) {
return "This class is currently purely abstract";
}
public String writeJava(String name, boolean extendsNormal,
boolean exporting) {
return "This class is currently purely abstract";
}
}

View File

@@ -7,9 +7,8 @@ import com.oroinc.text.regex.*;
import java.io.*;
public class PdePreprocessorOro extends PdePreprocessor {
static final String EXTENDS = "extends BApplet ";
static final String EXTENDS_KJC = "extends KjcApplet ";
//static final String EXTENDS = "extends BApplet ";
//static final String EXTENDS_KJC = "extends KjcApplet ";
static final String applet_imports[] = {
"java.applet", "java.awt", "java.awt.image", "java.awt.event",
@@ -55,8 +54,10 @@ public class PdePreprocessorOro extends PdePreprocessor {
static final int ADVANCED = 2;
// writes .java file into buildPath
public String writeJava(String name, boolean kjc) {
//System.out.println("writing java");
public String writeJava(String name, boolean extendsNormal,
boolean exporting) {
String extendsWhat = extendsNormal ? "BApplet" : "BAppletGL";
try {
int programType = BEGINNER;
@@ -140,15 +141,19 @@ public class PdePreprocessorOro extends PdePreprocessor {
tempClass = name;
// and we're running inside
if (kjc) { // if running inside processing...
index = program.indexOf(EXTENDS); // ...and extends BApplet
// no longer necessary, i think, since kjcapplet is gone
/*
if (!exporting) {
index = program.indexOf(extendsWhat); // ...and extends BApplet
if (index != -1) { // just extends object
String left = program.substring(0, index);
String right = program.substring(index + EXTENDS.length());
String right = program.substring(index + extendsWhat.length());
// replace with 'extends KjcApplet'
program = left + ((usingExternal) ? EXTENDS : EXTENDS_KJC) + right;
//program = left + ((usingExternal) ? EXTENDS : EXTENDS_KJC) + right;
program = left + extendsWhat + right;
}
}
*/
}
tempFilename = name + ".java";
tempClassFilename = name + ".class";
@@ -159,7 +164,7 @@ public class PdePreprocessorOro extends PdePreprocessor {
if (programType < ADVANCED) {
// spew out a bunch of java imports
if (kjc) { // if running in environment, or exporting an app
if (!exporting) { // if running in environment, or exporting an app
for (int i = 0; i < application_imports.length; i++) {
writer.print("import " + application_imports[i] + ".*; ");
}
@@ -174,14 +179,15 @@ public class PdePreprocessorOro extends PdePreprocessor {
// add serial if running inside pde
//if (kjc) writer.print("import javax.comm.*;");
if (!kjc) writer.println();
if (exporting) writer.println();
writer.print("public class " + name + " extends " +
((kjc && !usingExternal) ?
"KjcApplet" : "BApplet") + " {");
extendsWhat + " {");
//((kjc && !usingExternal) ?
//"KjcApplet" : "BApplet") + " {");
}
if (programType == BEGINNER) {
if (!kjc) writer.println();
if (exporting) writer.println();
// hack so that the regexp below works
//if (program.indexOf("size(") == 0) program = " " + program;
@@ -299,7 +305,7 @@ public class PdePreprocessorOro extends PdePreprocessor {
// especially when not in kjc mode (!kjc == export)
// things will be one line off if there's an error in the code
if (!kjc) writer.println();
if (exporting) writer.println();
writer.println(program);
//System.out.println(program);

View File

@@ -9,7 +9,8 @@ import java.io.*;
public class PdeRuntime implements PdeMessageConsumer {
Process process;
KjcApplet applet;
//KjcApplet applet;
BApplet applet;
PdeException exception;
Window window;
PdeEditor editor;
@@ -48,19 +49,16 @@ public class PdeRuntime implements PdeMessageConsumer {
this);
} else {
// temporarily disabled
//KjcClassLoader loader = new KjcClassLoader(buildPath);
//Class c = loader.loadClass(tempClass);
Class c = Class.forName(className);
//try {
applet = (KjcApplet) c.newInstance();
//} catch (Exception e) {
// e.printStackTrace();
//}
//System.out.println(c + " " + applet);
//((KjcApplet)applet).errStream = leechErr;
applet.setRuntime(this);
// to get rid of KjcEngine [fry]
//applet = (KjcApplet) c.newInstance();
applet = (BApplet) c.newInstance();
// replaces setRuntime with BApplet having leechErr [fry]
//applet.setRuntime(this);
applet.leechErr = leechErr;
// has to be before init
applet.serialProperties(PdeBase.properties);
applet.init();
@@ -201,7 +199,10 @@ public class PdeRuntime implements PdeMessageConsumer {
} catch (Exception e) {
// this will pass through to the first part of message
// this handles errors that happen inside setup()
newMessage = true;
// mod by fry for removal of KjcEngine
//newMessage = true;
leechErr.println(BApplet.LEECH_WAKEUP);
e.printStackTrace(this.leechErr);
//if (exception != null) throw exception;
}
@@ -259,10 +260,10 @@ public class PdeRuntime implements PdeMessageConsumer {
}
public void message(String s) {
//if (s.indexOf("MAKE WAY") != -1) {
//System.out.println("new message coming");
//newMessage = true;
if (s.indexOf(BApplet.LEECH_WAKEUP) == 0) {
newMessage = true;
return; // this line ignored
}
//} else {
if (newMessage) {

View File

@@ -1,4 +1,6 @@
# the usual 12 point from other platforms is too big on osx
editor.program.font = Monospaced,plain,10
editor.console.font = Monospaced,plain,10
# ... or another reasonable-looking option
#editor.program.font = Courier New,plain,11

View File

@@ -22,6 +22,10 @@ else
rm reference.zip
cd ..
# copy gl4java libs and jar file
cp ../../bagel/opengl/gl4java.jar work/lib/
cp ../../bagel/opengl/macosx/libGL4JavaJauGljJNI13.jnilib work/
mkdir work/lib/export
mkdir work/lib/build
@@ -40,6 +44,7 @@ else
sudo cp comm.jar /System/Library/Frameworks/JavaVM.framework/Home/lib/ext/
fi
### -- START BUILDING -------------------------------------------
# move to 'app' directory
@@ -65,10 +70,9 @@ MACOSX_CLASSPATH=/System/Library/Frameworks/JavaVM.framework/Classes/classes.jar
CLASSPATH=$MACOSX_CLASSPATH
### --- make version with serial for the application
### --- make version with all the goodies for the application
echo Building bagel with serial, video, and audio support
perl make.pl SERIAL VIDEO SONIC
#pwd
perl make.pl SERIAL VIDEO SONIC OPENGL
cp classes/*.class ../build/macosx/work/classes/
### --- make version without serial for applet exporting

6
build/macosx/run13.sh Executable file
View File

@@ -0,0 +1,6 @@
#!/bin/sh
cd work && /System/Library/Frameworks/JavaVM.framework/Versions/1.3.1/Commands/java -cp lib:lib/build:lib/pde.jar:lib/kjc.jar:lib/oro.jar:lib/gl4java.jar:../comm.jar PdeBase
# -Dcom.apple.hwaccel=false
#cd work && java -cp lib:lib/build:lib/pde.jar:lib/kjc.jar:lib/oro.jar:../comm.jar PdeBase

View File

@@ -3,6 +3,52 @@
..................................................................
_ remove lexer dir from cvs
1 _ horizontal scroller on the mac is enormous
_ is it possible to get rid of KjcApplet
_ better 'newMessage' trigger with the printstream
_ notify dmose about changes
_ history
_ do people even use it
_ oooh.. combine in app to show diffs
_ get proper tab comments into source files
_ get proper licensing info into source files
_ write notes about p5 code spec
_ console -> should be using JEditTextArea, not TextPane
_ scroll to most current line, or scroll as changing
_ set decent fonts (probably same as editor above), looks bad on mac
_ remove the border around the edge
_ what's with the 2 blank lines on startup?
ks b _ background(BImage)
ks b _ also creating background image inside setup()
bf b _ make bagel usable on its own as a drawing surface
bf b _ needs to be used as a component, without applet
bf b _ but retain functionality, ie. image i/o
bf b _ exports pixels or a BImage or does MemoryImageSource itself
bf b _ move math functions into utility library associated
bf b _ with bagel, because those will be useful on other bagel platforms
bf b _ pApplet will call BagelMath.whatever, so still looks like cos()
bf b _ opengl export / rendering mode
bf b _ currently implemented, but somewhat broken
bf b _ finish this once all the line code is done
bf _ look into eclipse ide a little more
bf _ platform parity issues
bf _ bring linux up to 1.4
bf _ ask on bboard about macosx 1.3 vs 1.4 experiences
bf _ upgrade windows to 1.4.2
bf _ too many frames drawn before window visible - especially on mac
bf b _ curves
bf b _ curveMode(), curveMode to tweak the s parameter of catmullrom
bf b _ setting accuracy of curve segments
@@ -10,6 +56,7 @@ bf b _ right now it's hardwired at 20, should be adjustable
bf b _ function to evaluate bezier or catmullrom points
bf b _ used heavily in genome valence, asked about on the bboard
bf b _ http://proce55ing.net/discourse/yabb/YaBB.cgi?board=Proce55ing_Software;action=display;num=1053449577;start=0
bf b _ http://proce55ing.net/discourse/yabb/YaBB.cgi?board=Proce55ing_Software;action=display;num=1057393989;start=0
bf b _ perlin noise 1D. noise()
@@ -24,6 +71,13 @@ bf b _ fix link() and loadStream code once that's fixed
bf b _ if sketchbook.dir is set, makes new sketchbook folder
bf b _ reads sketchbook properly from other folder
bf b _ but creates a new folder for new sketches to go into
bf b _ remove the 'default' for sketchbook
bf b _ install sketchbook into another location on person's machine
bf b _ bring this up on bboard and get votes
bf b _ win2k: my documents, macosx: ~/Documents,
bf b _ macos9: hd:Users?, linux: ~/sketchbook
bf b _ move examples to folder that goes w/ p5 app
bf b _ set examples somehow read-only
bf b _ tweak video to get it working
bf b _ beginVideo(int, int, int) not found
@@ -80,17 +134,6 @@ ks b _ resize of bimage, make a copy of image?
ks b _ http://proce55ing.net/discourse/yabb/YaBB.cgi?board=Proce55ing_Software;action=display;num=1050328581
ks b _ getPixel() and other fxns for BImage
ks b _ background(BImage)
ks b _ also creating background image inside setup()
bf b _ make bagel usable on its own as a drawing surface
bf b _ needs to be used as a component, without applet
bf b _ but retain functionality, ie. image i/o
bf b _ exports pixels or a BImage or does MemoryImageSource itself
bf b _ move math functions into utility library associated
bf b _ with bagel, because those will be useful on other bagel platforms
bf b _ pApplet will call BagelMath.whatever, so still looks like cos()
bf b _ light(x, y, z, c1, c2, c3, TYPE)
bf b _ also BLight with same constructor, and on() and off() fxn
@@ -162,10 +205,6 @@ ks b _ finish fill mode of flat circle function
ks b _ stroked version of sphere is just a circle (?)
ks b _ setting accuracy of circles/sphere
b _ opengl export / rendering mode
b _ currently implemented, but somewhat broken
b _ finish this once all the line code is done
bf b _ illustrator export / rendering mode
bf b _ also postscript or pdf export?
bf b _ version of Illustrator.java that uses bagel api