Last modified 15 years ago
Last modified on 10/02/09 12:04:23
Analysis
- The goal of this task is to integrate the new text into Sophie with all existing old functionality and addition of new features.
Overview
- Handle Priority 2 and 3 tasks specified in HOT_TEXT_REDESIGN_R1.
- Integrate text with new resources
- Make persisters for all needed classes
- Make AutoActions for all Operations in the Logic that change the text
- Text and Text Layout performance
- Use a profiler to find problems
- Control memory consumption
- Implement Chaining using the existing old functionality and the new design.
- Implement Anchoring (as a separate task)
- Extend the text usability documentation with proper uses of text by the client code.
Task requirements
- Implement the tasks specified in the Overview
- Anchoring is optional
Task result
- Source code
- Wiki page (text documentation)
Implementation idea
- Specified in the Overview section
Related
How to demo
Design
- Integration of the new text into Sophie
- Models
- Views
- Text Views
- A new TextView abstract class is added that contains:
- A TextViewFlow holding the data needed by the view
- Text
- Areas
- Text layout
- Mark position
- Caret position
- Extra highlights (from searches, etc.)
- Editable flag
- Note: By extending the flow the text view's state could be diversified.
- A DefaultTextViewFlow class should be created to encapsulate the common logic, so that is can be reused by different ElementViews displaying text (text frames, comment frames, stickies, etc.).
- The index of the view in a possible sequence of views (chaining or other)
- Interaction map
- Note: By extending the TextView itself its drawing logic could be diversified.
- A TextViewFlow holding the data needed by the view
- SceneTextView inheriting TextView is added.
- It is abstract to allow overriding of its model.
- Contains the scene element.
- SwingTextView inheriting TextView is added to use swing drawing.
- A new TextView abstract class is added that contains:
- Text Views
- Element views
- A new HotTextView interface is added to enforce the usage of TextView class.
- HeadTextFrameView is created to represent either a single view or a view which is the head of a chain.
- It contains the (shared) flow of the whole chain.
- TailTextFrameView is created to represent a view which is chained.
- It refers to its related HeadTextFrameView in the chaining.
- Through the head view it accessed its TextViewFlow.
- Logics
- Modify the operation for creation of a text frame (ON_ADD_TEXT_FRAME) to use AutoActions, new resources and new text.
- Create a new TextFlowLogic class with the following responsibilities
- It is a basic logic and has no knowledge of how to set the model.
- Handles all text events.
- Calculates the needed changes to the text.
- Fires a new SET_TEXT event to be handled by the logics that should set the model.
- Updates the flow (the view state).
- Create the logics that modify the model
- SimpleTextLogic
- Directly sets the text to the SimpleTextFlow of the view
- Mainly used for testing purposes
- HotTextLogic
- Sets text to the model through AutoAction.
- Adding a new text frame moved to HotTextLogic.
- SimpleTextLogic
- Styling
- Can be applied in two ways
- For a whole interval - range of positions
- Default behaviour: The style is applied from the position before the first character of the interval to the position before the first character after the interval.
- Typing interactions before the interval are not styled with the applied style
- Typing interactions right after the interval are styled with the applied style
- Example:
- Styled text - "Test text"
- Input chars - "Test tTexTt"
- For a single position
- Default behaviour: The style is applied only for the position itself.
- Typing interactions at the position are styled with the applied style
- Example:
- Styled text - "Test text" with applied style between 'x' and 't'.
- Input chars - "Test texTt"
- For a whole interval - range of positions
- Styles are applied through the TextFontHud on the current selection interval.
- TextView.EventIds.APPLY_STYLE event id is fired to handle styling interactions.
- It has two parameters - style attribute and value.
- The event is handled the same way as other modifying operations on text - a new SET_TEXT event is fired to set the new text with applied style.
- Can be applied in two ways
- Persistence
- ImmHotText should be persisted based on
- Its string representation (already present).
- Its style values.
- Should be persisted as mapping of pairs (HotAttr.id, style value set).
- The style value set should be persisted as mapping of pairs (HotPos, style value).
- HotPos should be persisted based only on its index.
- Save
- The history of text is not saved
- All HotPoses should be converted (new positions created) to belong to the saved ImmHotText (not some of its past or future relatives in the history).
- Create a method ImmHotText.getNormalizedStyleValues() for this purpose.
- Load
- Load the text itself
- Load the styles
- Convert styles to conform to the loaded text (HotPoses should be compared by the loaded text's comparator)
- Create a new factory method to create ImmHotText by its internals.
- ImmHotText should be persisted based on
- Chaining is done in a separate task: TEXT_CHAINING_BEHAVIOUR_R1
- Testing:
- A new ImmHotTextTest added to test all basic ImmHotText functionalities including:
- Applying styles.
- Replace of text (with styles).
- Insert of a character at some position in the text (with styles) - this test fails, it will be fixed as part of the implementation.
- Sub-text (with styles).
- Functionality needed by persistence.
- String representation and getters.
- SwingDemoTest renamed to HotTextDemoTest.
- HotLayoutTest extended to cover all HotLayout functionalities.
- NavigationTest extended.
- Tests are committed in a separate branch: branches/private/vlado/hot-text-redesign-r2
- A new ImmHotTextTest added to test all basic ImmHotText functionalities including:
Implementation
- A new branch is created for the current task: branches/private/vlado/hottext-r2
- Changesets:
- The following bugs are fixed:
- 1989 - Crash with navigation out of the frame area.
- 1971 - Navigation behavior with Home and End buttons.
- 1972 - Navigation behavior with Ctrl key pressed.
- 1973 - Undo of text modification grouped. The cursor should be moved to the place of the last modification. Also undo crashes and does not consider the changes on text itself.
- The problem with applying characters color (fixed) and background color (should be fixed but can not be tested due to incorrect behavior of the hud).
- Style values persistence.
- Note: For issues on testing check the known issues.
- Bugs in immutable structures persisters.
- Problems with chaining
- Crash with Reader.
- User feedback
- The specified case is not reproducible as a book can not be exported as .rtf at the moment.
- Persistence of styles is done, so the problem should not appear any more.
- The problem with characters color is fixed.
- Known issues (present in trunk)
- If style values are applied to the current text the font hud does not always show the correct font properties of the caret position.
- Closing a book and loading it again does not test any persistence. Usually it restores the frames from the cache. For testing of styles persistence Sophie should be restarted.
- Chaining persistence is broken (will be corrected with integration of Boyan's autochaining task)
Merged to the trunk at [7177].
Testing
(Place the testing results here.)
Comments
(Write comments for this or later revisions here.)
Attachments
- text-views.png (98.4 KB) - added by vlado 16 years ago.
- text-frame-views.png (53.9 KB) - added by vlado 16 years ago.