Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > word processing

Reply
Thread Tools

word processing

 
 
bob@coolgroups.com
Guest
Posts: n/a
 
      09-24-2005
What sort of data structures would be best for storing a document for a
word processing program in memory (it supports images/text and various
font sizes/faces... think Microsoft Word)? I got this wrong in an
interview and am curious about it.

 
Reply With Quote
 
 
 
 
Roedy Green
Guest
Posts: n/a
 
      09-24-2005
On 24 Sep 2005 15:45:03 -0700, http://www.velocityreviews.com/forums/(E-Mail Removed) wrote or quoted :

>What sort of data structures would be best for storing a document for a
>word processing program in memory (it supports images/text and various
>font sizes/faces... think Microsoft Word)? I got this wrong in an
>interview and am curious about it.


JTextPane. It will work with HTML or RTF. You can cook up a simple
word processor in a few lines.

http://mindprod.com/jgloss/jtextpane.html
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.
 
Reply With Quote
 
 
 
 
Jeff Schwab
Guest
Posts: n/a
 
      09-24-2005
Roedy Green wrote:
> On 24 Sep 2005 15:45:03 -0700, (E-Mail Removed) wrote or quoted :
>
>
>>What sort of data structures would be best for storing a document for a
>>word processing program in memory (it supports images/text and various
>>font sizes/faces... think Microsoft Word)? I got this wrong in an
>>interview and am curious about it.

>
>
> JTextPane. It will work with HTML or RTF. You can cook up a simple
> word processor in a few lines.
>
> http://mindprod.com/jgloss/jtextpane.html


JTextPane is not a data structure, it's a GUI component.

There are plenty of ways to store text in memory, but I am partial to
arrays or linked lists of lines.
 
Reply With Quote
 
zero
Guest
Posts: n/a
 
      09-24-2005
Jeff Schwab <(E-Mail Removed)> wrote in news:lsOdnV8MQMqVQKjeRVn-
(E-Mail Removed):

> Roedy Green wrote:
>> On 24 Sep 2005 15:45:03 -0700, (E-Mail Removed) wrote or quoted :
>>
>>
>>>What sort of data structures would be best for storing a document for a
>>>word processing program in memory (it supports images/text and various
>>>font sizes/faces... think Microsoft Word)? I got this wrong in an
>>>interview and am curious about it.

>>
>>
>> JTextPane. It will work with HTML or RTF. You can cook up a simple
>> word processor in a few lines.
>>
>> http://mindprod.com/jgloss/jtextpane.html

>
> JTextPane is not a data structure, it's a GUI component.
>
> There are plenty of ways to store text in memory, but I am partial to
> arrays or linked lists of lines.


Would be hard to include the images, fonts, colours, ...

How about a tree-like structure with nodes that define the text attributes
and leaves with the actual text or embedded objects.

If you're looking for an existing Java class, then StyledDocument and its
implementing classes is the obvious choice. I believe a JTextPane uses a
StyledDocument internally too.
 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      09-25-2005
On Sat, 24 Sep 2005 19:11:01 -0400, Jeff Schwab
<(E-Mail Removed)> wrote or quoted :

>> http://mindprod.com/jgloss/jtextpane.html

>
>JTextPane is not a data structure, it's a GUI component.


It uses the Document interface for the model part which would be
implemented for example by HTMLDocument.

--
Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.
 
Reply With Quote
 
Chris Smith
Guest
Posts: n/a
 
      09-25-2005
Roedy Green <(E-Mail Removed)> wrote:
> On Sat, 24 Sep 2005 19:11:01 -0400, Jeff Schwab
> <(E-Mail Removed)> wrote or quoted :
>
> >> http://mindprod.com/jgloss/jtextpane.html

> >
> >JTextPane is not a data structure, it's a GUI component.

>
> It uses the Document interface for the model part which would be
> implemented for example by HTMLDocument.


Yes, but in a quite profound sense, Jeff is right. JTextPane is NOT a
data structure. It's an interface, and with some effort can be
implemented to provide a way of accessing information from any number of
data structures.

For example, I have a back-burner project for work right now. We want
to implement Swing's Document to provide a transparent adapter to a W3C
DOM, such that the authoritative copy of the data is kept in the W3C
DOM, and the Swing Document class is only used to get data from there to
the JEditorPane for display. I could do the same thing for a different
data structure format that's not even remotely tree-based at all. If
so, you just make up the tree structure synthetically inside the model
adapter.

So no, JTextPane really isn't a data structure, nor does it imply any
specific data structure.

--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      09-25-2005
On Sun, 25 Sep 2005 07:43:34 -0600, Chris Smith <(E-Mail Removed)>
wrote or quoted :

>Yes, but in a quite profound sense, Jeff is right. JTextPane is NOT a
>data structure. It's an interface, and with some effort can be
>implemented to provide a way of accessing information from any number of
>data structures.


OP asked "What sort of data structures would be best for storing a
document for a word processing program in memory".

For that he needs both a GUI and memory model.

There is no rule that says you must answer every question literally.

A pox on any prissy nerd who bawls someone out for suggests reading up
on JTables when a newbies asks how do you store table data for display
..
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.
 
Reply With Quote
 
Monique Y. Mudama
Guest
Posts: n/a
 
      09-26-2005
On 2005-09-24, (E-Mail Removed) penned:
> What sort of data structures would be best for storing a document
> for a word processing program in memory (it supports images/text and
> various font sizes/faces... think Microsoft Word)? I got this wrong
> in an interview and am curious about it.


What was your answer?

Typically, an interview question should be about finding out whether
you can think through a problem, not necessarily being right. If they
had a single data structure in mind and marked you "wrong" for not
being a mind reader, well, that wasn't a good interview technique.

--
monique

Ask smart questions, get good answers:
http://www.catb.org/~esr/faqs/smart-questions.html
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
String processing: word replacement anhtt@hotmail.com C++ 6 04-07-2005 12:20 PM
Post-Processing RAW vs Post-Processing TIFF Mike Henley Digital Photography 42 01-30-2005 08:26 AM
.NET Word processing component Martin ASP .Net 6 11-09-2004 02:44 AM
Question: processing HTML, re-write default processing action of many tags Hubert Hung-Hsien Chang Python 2 09-17-2004 03:10 PM
Email format in word processing programs Jim Beaver Computer Support 7 05-10-2004 12:29 AM



Advertisments