word processing

Discussion in 'Java' started by bob@coolgroups.com, Sep 24, 2005.

  1. Guest

    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.
     
    , Sep 24, 2005
    #1
    1. Advertising

  2. Roedy Green Guest

    On 24 Sep 2005 15:45:03 -0700, 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.
     
    Roedy Green, Sep 24, 2005
    #2
    1. Advertising

  3. Jeff Schwab Guest

    Roedy Green wrote:
    > On 24 Sep 2005 15:45:03 -0700, 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.
     
    Jeff Schwab, Sep 25, 2005
    #3
  4. zero Guest

    Jeff Schwab <> wrote in news:lsOdnV8MQMqVQKjeRVn-
    :

    > Roedy Green wrote:
    >> On 24 Sep 2005 15:45:03 -0700, 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.
     
    zero, Sep 25, 2005
    #4
  5. Roedy Green Guest

    On Sat, 24 Sep 2005 19:11:01 -0400, Jeff Schwab
    <> 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.
     
    Roedy Green, Sep 25, 2005
    #5
  6. Chris Smith Guest

    Roedy Green <> wrote:
    > On Sat, 24 Sep 2005 19:11:01 -0400, Jeff Schwab
    > <> 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
     
    Chris Smith, Sep 25, 2005
    #6
  7. Roedy Green Guest

    On Sun, 25 Sep 2005 07:43:34 -0600, Chris Smith <>
    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.
     
    Roedy Green, Sep 25, 2005
    #7
  8. On 2005-09-24, 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
     
    Monique Y. Mudama, Sep 26, 2005
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Martin

    .NET Word processing component

    Martin, Nov 8, 2004, in forum: ASP .Net
    Replies:
    6
    Views:
    571
    Martin
    Nov 9, 2004
  2. Replies:
    6
    Views:
    2,999
    Jeff Flinn
    Apr 7, 2005
  3. questioner
    Replies:
    0
    Views:
    341
    questioner
    May 4, 2004
  4. Hubert Hung-Hsien Chang
    Replies:
    2
    Views:
    525
    Michael Foord
    Sep 17, 2004
  5. Timasmith
    Replies:
    1
    Views:
    654
    Knute Johnson
    Mar 13, 2007
Loading...

Share This Page