Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.gui > #2029
| From | "Roedy Green" <roedy.green@THRWHITE.remove-dii-this> |
|---|---|
| Subject | Re: in-place editing of t |
| Message-ID | <l2rc93533oolm0gilduj89mpc293ubjjnf@4ax.com> (permalink) |
| Newsgroups | comp.lang.java.gui |
| References | <1184241348.359167.82880@o61g2000hsh.googlegroups.com> |
| Date | 2011-04-27 15:36 +0000 |
| Organization | TDS.net |
To: comp.lang.java.gui On Thu, 12 Jul 2007 04:55:48 -0700, ravi.phor.U@gmail.com wrote, quoted or indirectly quoted someone who said : >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 --- * 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 — Previous in thread | Find similar | Unroll thread
in-place editing of text "ravi.phor.U" <ravi.phor.u@THRWHITE.remove-dii-this> - 2011-04-27 15:36 +0000 Re: in-place editing of t "Roedy Green" <roedy.green@THRWHITE.remove-dii-this> - 2011-04-27 15:36 +0000
csiph-web