fixes to bagel and processing for multi-font size, setting g.applet, bugs in stream

This commit is contained in:
benfry
2002-01-23 18:12:57 +00:00
parent 14d0e8a25e
commit b8698d128c
2 changed files with 70 additions and 9 deletions

View File

@@ -87,10 +87,10 @@ public class ProcessingApplet extends Applet
}
//public Dimension getPreferredSize() {
//println("getting pref'd size");
//return new Dimension(width, height);
//}
public Dimension getPreferredSize() {
//println("getting pref'd size");
return new Dimension(width, height);
}
// ------------------------------------------------------------
@@ -232,6 +232,11 @@ public class ProcessingApplet extends Applet
g = new Bagel(width, height);
pixels = g.pixels;
// set this here, and if not inside browser, getDocumentBase()
// will fail with a NullPointerException, and cause applet to
// be set to null. might be a better way to deal with that, but..
g.applet = this;
// do all the defaults down here, because
// subclasses need to go through this function
g.lighting = false;
@@ -696,6 +701,47 @@ public class ProcessingApplet extends Applet
*/
// ------------------------------------------------------------
// run as application
static public void main(String args[]) {
if (args.length != 1) {
System.err.println("error: ProcessingApplet <appletname>");
System.exit(1);
}
try {
Frame frame = new Frame();
Class c = Class.forName(args[0]);
ProcessingApplet applet = (ProcessingApplet) c.newInstance();
applet.init();
applet.start();
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
frame.add(applet);
frame.pack();
frame.setLocation((screen.width - applet.g.width) / 2,
(screen.height - applet.g.height) / 2);
frame.show();
applet.requestFocus(); // get keydowns right away
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
} catch (Exception e) {
e.printStackTrace();
System.exit(1);
}
}
// ------------------------------------------------------------
// public functions from bagel
@@ -856,6 +902,11 @@ public class ProcessingApplet extends Applet
}
public void setFont(BagelFont which) {
g.setFont(which);
}
public void setFont(BagelFont which, float size) {
g.setFont(which, size);
}
@@ -1069,13 +1120,13 @@ public class ProcessingApplet extends Applet
}
public void smoothingOn() {
g.smoothingOn();
public void hint(int which) {
g.hint(which);
}
public void smoothingOff() {
g.smoothingOff();
public void unhint(int which) {
g.unhint(which);
}