Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.gui > #4436
| From | "ram" <ram@THRWHITE.remove-dii-this> |
|---|---|
| Subject | Re: Looking for a simple |
| Message-ID | <painting-20081107164213@ram.dialup.fu-berlin.de> (permalink) |
| Newsgroups | comp.lang.java.gui |
| References | <252e7276-6bd1-4c07-ac29-dbc6318f3801@w39g2000prb.googlegroups |
| Date | 2011-04-27 15:50 +0000 |
| Organization | TDS.net |
To: comp.lang.java.gui
Simo Melenius <simo.melenius@gmail.com> writes:
>What I seem to need most often is a simple API/library to open
>a window and draw some graphics to its bitmap. Aside from AWT
>and Java2D, are there any de facto libraries that Java
>programmers frequently use for such purpose?
Because of the structure of Java, one would need a framework
(not a library) for this. (You call a library, while a
framework calls you.)
The framework would open a window and pass the graphics
context to your +hook method2 (aka call-back).
An example of such a framework are web browsers, which
execute Java applets. Your applet is called from the browser
and is given a graphic context, so that you can start
painting immediately, IIRC.
Most Java-programmers do not use such a framework, because
opening a window so that one can draw on it only takes a few
lines of code. But you need to /know/ how to do it. You might
start here:
http://java.sun.com/docs/books/tutorial/uiswing/painting/
Also have a look at the example code for drawing and
animation that comes with Java: +Java\jdk...\demo\jfc\Java2D2
(source code included).
There also are additional libraries for graphics:
http://schmidt.devlib.org/jiu/links.html
>I would hope to find something that is less complex and object
>oriented than AWT and more imperative, thus making it suitable for
>being run directly from Clojure REPL (where I would basically have one
>function which opens the window, loops reading events, doing
>something, and rendering, and then closes down everything upon
>exiting).
Clojure wants to be +functional2 - not +procedural2.
And +functional2 is close to +object oriented2, because
in both cases you pass in call-backs (= first class functions
or +blocks2).
procedural (C) pseudocode:
if( canvas = opencanvas( 640, 480 ))
{ drawto( canvas );
close( canvas ); }
object-oriented (Smalltalk) pseudocode:
withcanvas( 640, 480,[ canvas: drawto( canvas )])
Common-Lisp-like pseudocode:
( with-open-canvas 640 480
( lambda canvas ( drawto canvas )))
---
* Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24
Back to comp.lang.java.gui | Previous | Next | Find similar | Unroll thread
Re: Looking for a simple "ram" <ram@THRWHITE.remove-dii-this> - 2011-04-27 15:50 +0000
csiph-web