Analysis
Overview
In BASE_MODEL_TEXTS task the model and the functionality for the text elements should be defined. The model should allow the creation of chained views, styling of text, rotation, transparency and different modes of wrapping . It should allow persisting of texts along with all the applied attributes. The task consists of two logical parts
- a model for the text itself
- a model for the view components.
- Text model
- The model for the text consist of styled text and contains information about the attributes of the text itself
- font
- size
- color
- opacity
- modifiers (bold, italic, underline, strikethrough)
- attached actions
- other attributes that may appear
- The chained view components will share a common text model and each will display only part of it.
- A mechanism for persisting this models should be designed and it should be consistent with the overall persistent strategy in Sophie (BASE_PERSISTENCE_INTERMEDIATE_STORAGE_R0, BASE_PERSISTENCE_COMMONS_R0)
- An undo/redo mechanism should be designed in a way that will allow it so seamlessly integrate with the properties oriented undo/redo mechanism used in Sophie (PRO_CHANGE_UNDO_MANAGER_R0).
- The model for the text consist of styled text and contains information about the attributes of the text itself
- Individual text component model
- The model of the individual text component should contain additional information for the rendering of the text in the particular view
– transparency
- rotation
- wrapping mode
- other attributes that may appear
- The view component model should contain information what part of the text model it should display, in the case of chained views.
- A mechanism should exist that will trigger recalculation of the ranges of the texts displayed in different chained views if some change is made in one of them, causing its range to change. Among this kind of changes include
- insert/remove/replace text
- change the size of the view component
- changes in the size of some part of the text inside the component
- change the wrapping mode of the component
- maybe other
- The model of the individual text component should contain additional information for the rendering of the text in the particular view
– transparency
Considering the complexity of this task it is probable that parts of it will have to be moved to separate tasks and, in addition, unplanned related tasks can emerge. Such tasks have to be identified and described, during the work. Such tasks may be, for example, the persistence mechanism, the undo/redo mechanism, the attachment of actions (hyperlink style) to the text, and others.
Task requirements
For the R_0 focus on following requirements:
- The model should support chaining of views.
- The model should support styling of the text.
- The model should support selection split over more than one view. (selection of text starting in one view and continuing in another)
Task result
The result of this task should be design description and only a prove of concept prototype implementation code.
Implementation idea
- Create EditorKit ( probably extend the StyledEditKit or RtfEditKit) to support the coordination of multiple chained views, split selection, and persistence
- Create DocumentModel (probably extend StyledDocument) to contain appropriate element structure that will support the required functionality. Eventually create a MasterDocument containing all the text and ChainedDocument to represent only part of it displayed in a single component view, using the MasterDocument as a backend.
- Register appropriate UndoableEditListener and implement integration with with the undo/redo mechanism used in Sopie (PRO_CHANGE_UNDO_MANAGER_R0)
- Define the attributes that will describe the text and will be acceptable in the AttributesSets of the elements in the document.
Related
BASE_PERSISTENCE_INTERMEDIATE_STORAGE_R0
BASE_PERSISTENCE_COMMONS_R0
WRAPPING_TEXT_RENDERING_R0
PRO_CHANGE_UNDO_MANAGER_R0
How to demo
- Create a frame containing more than one text views over the same model, prefilled with text, with at least two different styles.
- Observe the different styles
- Type some text in the views and observe the splitting of the text on different views.
- Select some text with part of the selection at the end of the first view and part – at the beginning of the second.
- Copy and paste the selected text to ensure the selection is correct
Design
Implementation
(Implementation results should be described and linked here (from the wiki or the repository))
Testing
Comments
In future releases the model will probably have to support also the following functionality: undo/redo, custom styles, attaching actions to text ( hyperlinks style), pagination, search/replace, spell check, read/write to stream/reader/writer (serialize)