From b8698d128cb620baba03b28d09deff6c82cfb947 Mon Sep 17 00:00:00 2001 From: benfry Date: Wed, 23 Jan 2002 18:12:57 +0000 Subject: [PATCH] fixes to bagel and processing for multi-font size, setting g.applet, bugs in stream --- processing/app/ProcessingApplet.java | 67 ++++++++++++++++++++++++---- processing/todo.txt | 12 ++++- 2 files changed, 70 insertions(+), 9 deletions(-) diff --git a/processing/app/ProcessingApplet.java b/processing/app/ProcessingApplet.java index 63a9d5b81..03f1f09a9 100644 --- a/processing/app/ProcessingApplet.java +++ b/processing/app/ProcessingApplet.java @@ -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 "); + 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); } diff --git a/processing/todo.txt b/processing/todo.txt index fcd77eb31..10ed77d06 100644 --- a/processing/todo.txt +++ b/processing/todo.txt @@ -18,6 +18,7 @@ Michael McGuffin Anthony Okolie Luis Miguel P. Daniel Evan Schwartz +Enrico Trujillo Jeff Williams Ian Wojtowicz andres @@ -131,12 +132,21 @@ _ add hint for super smooth fonts _ add preferredsize to processingapplet X bug in Bagel.loadImage that made images not work in applets _ millis returns 0 (though getMillis() is fine) +X catch exception inside polygon scanner (slower?) +_ rewrite fill/stroke/etc to use same code +_ doesn't need to be super fast, so the extra assigns no big deal + +_ WRITE CONVERTER FROM JAVA BAGEL -> CPP +_ include #ifdefs for c stuff + +_ try with 1.4 frame buffer stuff to see if it's faster +_ will 1.4 work on osx? _ it's really a pain to use external files in processing _ getStream sucks (zach rewrote) _ should be able to work for application or applets _ may want to use getResource() (to get things from .jar files) - +_ fix buzz.pl to not create ../../bagel _ need to clamp colors (nothing > 255 or < 0) _ try using serial events from javacomm instead of just reading straight _ paren problems comes from overusing parens (too many closing)