Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.gui > #2018 > unrolled thread

in-place editing of text

Started by"ravi.phor.U" <ravi.phor.u@THRWHITE.remove-dii-this>
First post2011-04-27 15:36 +0000
Last post2011-04-27 15:36 +0000
Articles 2 — 2 participants

Back to article view | Back to comp.lang.java.gui


Contents

  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

#2018 — in-place editing of text

From"ravi.phor.U" <ravi.phor.u@THRWHITE.remove-dii-this>
Date2011-04-27 15:36 +0000
Subjectin-place editing of text
Message-ID<1184241348.359167.82880@o61g2000hsh.googlegroups.com>
  To: comp.lang.java.gui
Hi All,

We are working on a Whiteboard application. We have a feature where
text can be written on the canvas. Currently we popup up a dialog to
enter text to be written and then use a text area to display it on the
canvas.
We would like to have in-place text editing without moving to a
separate dialog. Can anyone give some pointers as to how it can be
achieved. We would also like to use rich text editing (using multiple
colors and fonts in the same text.) Any help is appreciated.

Thank you for reading
cheers

Ravi

---
 * 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

[toc] | [next] | [standalone]


#2029 — Re: in-place editing of t

From"Roedy Green" <roedy.green@THRWHITE.remove-dii-this>
Date2011-04-27 15:36 +0000
SubjectRe: in-place editing of t
Message-ID<l2rc93533oolm0gilduj89mpc293ubjjnf@4ax.com>
In reply to#2018
  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

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.java.gui


csiph-web