>We would like to have in-place text editing without moving to a
>separate dialog.
see http://mindprod.com/jgloss/event11.html
Basically you will have field keystroke events, and keep a map of
strings and where they should be painted.
Every time you get a paint request, you quickly find the strings that
overlap the clip region and render them with drawString.
A suitable structure might be an ArrayList sorted by y. You can then
use binary search to rapidly find the first and last string to paint.
For each string, you have a reference to a Font object, a Color
object, and a text string.
Next you probably want commands to move, delete, edit etc. Basically
the key here is to field a mouse click event, then find the string in
your list closest to the click. The Hanging Moss algorithm
http://mindprod.com/jgloss/hangingmoss.html might be the way to fly if
you have a lot of strings. If there are only a few, a linear search
should suffice. It determining distance, you need only a rough
metric. e.g..
(abs (x1-x2) + abs( y1-y2)
or
(( x1-x2)*(x1-x2)+( y1-y2)*(y1-x2)
You might have a look at the code for JDisplay. It uses lists of
Tokens (that give text, colour and font) and renders them. It does not
support on the fly editing, but it does support finding which strings
to render given the clipregion. You could use that code unmodified to
do a write-only white-board. See
http://mindprod.com/products1.html#JDISPLAY
I think you will discover hundreds of people have written similar apps
before you, at least primitive ones. Do some digging for open source.
Even Java In A Nutshell has a primitive example.
http://mindprod.com/jgloss/nutshell.html
--
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com