Perfect

Feb 10, 2009 04:59

http://www.processing.org/faq.html#java

The main rule when using Java code: You cannot use most of the AWT or Swing (which is built on the AWT), because it will interfere with the graphics model. If you want to add scroll bars and buttons to your projects, you should make them ( Read more... )

Leave a comment

Comments 4

skydiamonde February 10 2009, 14:42:35 UTC
I don't know really anything about simulations but:

I've played around with Processing before and it's fun and pretty easy to do a lot with. Swing and AWT definitely do suck.

Could you just use some sort of AJAX? jQuery or DOJO or something?

Reply


buoren February 13 2009, 01:34:02 UTC
I've actually found the stuff they did in Processing easy enough to rewrite the basics for in Java swing... you end up reimplementing their rendering draw-panel, but it turns out you can make response times faster.

...of course, this was from a codebase about three years ago, so I don't know how much better it is these days.

-kevin

Reply

r_transpose_p February 13 2009, 03:34:48 UTC
Huh, I will keep that in mind...

I did find Processing fairly novice-friendly (as I was able to cut to
"let me draw some double-buffered animated graphics" without learning a lot of setup)

http://www.soe.ucsc.edu/~mds/chaos_playing1/applet/

Reply

r_transpose_p February 24 2009, 01:44:24 UTC
You were right -- it turns out it was much easier to add double-buffering and anti-aliasing to the existing simulations using AWT than it would have been to wrap them in a Processing interface.

Turns out there are two pieces of magic
  1. Never draw directly to the screen using anything other than "drawImage", ideally make one big image whose size is the size of the screen you want, do everything to that, and then draw that to the screen.
    Existing "draw to the screen" code is easy enough to port, using
    the "getGraphics" method on the image you just made to make a graphics context.
  2. It turns out one can "turn on antialiasing" just by telling a graphics context to "turn on antialiasing"

    gOffscreen.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
    RenderingHints.VALUE_ANTIALIAS_ON);


Also : http://www.soe.ucsc.edu/~mds/cclsim

Reply


Leave a comment

Up