Analysis
Overview
A paragraph is a self-contained unit of a discourse in writing dealing with a particular point or idea. The start of a paragraph is indicated by beginning on a new line. Sometimes the first line is indented; sometimes it is indented without beginning a new line. At various times the beginning of a paragraph has been indicated by the pilcrow: ¶.
User should be able to specify spacing setting for specific paragraph via paragraph settings hud.
Identation defines where does the text begin in the frame.Following settings should present:
- Right indent - defines the space after the text, for now in points.
- Left indent - defines the space before the text, for now in points.
- First line indent - defines the space before the first line in the text, for now in points.
- Space above - defines the space above the paragraph, for now in points.
- Space below - defines the space below the paragraph, for now in points.
- Line spacing - defines spacing between the lines in the paragraph, in lines. The default is 1.
Task requirements
- Implement indent functionalities for the paragraph
- Create a paragraph hud(OPTIONAL IF NOT FINISHED WILL BE INCLUDED IN THE NEXT REVISION)
- Should contain controls for align, character style and indents. (add only indent controls)
Task result
- The result should be code.
Implementation idea
- Review TEXT_PARAGPRAPH_FORMAT_COMMONS_R0 and don't get in to a conflict with implementation of this task.
- Also review what is implemented at this point.
- If there is a need review http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/text/StyleConstants.html
- See
Related
TEXT_PARAGPRAPH_FORMAT_COMMONS_R0
TEXT_PARAGRAPH_ALIGN_R0
TEXT_PARAGRAPH_STYLE_TEMPLATES_R0
TEXT_PARAGRAPH_CHAR_STYLE_R0
TEXT_PARAGRAPH_NEXT_STYLE_R0
DETACHED_TEXT_FRAME_EDITOR_R0
http://en.wikipedia.org/wiki/Paragraph
How to demo
- Run the application
- Create a new book and place text frame inside
- Populate some lorem ipsum text inside with a number of paragraphs(lorem ipsum generator --> http://www.lipsum.com/)
- Open the paragraph settings hud and manipulate spacing controls.
Design
- Add CommonAttr.PG_BEGIN and CommonAttr.PG_END attributes to represent existence of baragraph breaks in the style.
- Add HotTextLogic.INSERT_PARAGRAPH_BREAKS to represent the logic for properly adding paragraph attributes on enter in a HotText.
On enter:
- the HotUnit after the current caret position gets a derive HotStyleDef for its preStyle. The new style is concatination of the old one plus
PG_BEGIN attribute.
- the HotUnit before the current caret position gets a derive HotStyleDef for its postStyle. The new style is concatination of the old one plus
PG_END attribute.
- Create utility class ParagraphUtils with:
- static method checkCorrectness(HotText) - checks if PG_BEGIN and PG_END are nested correctly(every begin attribute has it's end attribute and after a begin attribute only an end attribute can be placed).
- static method existsBeginParagraph(HotStyleDef) - checks if there is PG_BEGIN in the specified style.
- static method existsEndParagraph(HotStyleDef) - checks if there is PG_END in the specified style.
- Layout
- Extend Atom class functionality with paragraph related attributes:
- Add Atom.isParaBegin to check for PG_BEGIN attribute.
- Modify Atom.isParaEnd to check for PG_END attribute.
- Methods for indentation, top and bottom spacing, etc.
- Add VertexFields values for the needed paragraph properties:
- Alignment
- Top spacing
- Bottom spacing
- Line spacing
- First line indent
- Left indent
- right indent
- Modify the layout algorithm:
- EdgeKind.OPEN_LINE to check for PG_BEGIN .
- EdgeKind.CLOSE_LINE to check for PG_END.
- EdgeKind.SEGMENT to check for PG_BEGIN and PG_END .
- To apply the paragraph visualization properties as follows:
- EdgeKind.OPEN_LINE - top spacing, line spacing, first line indent, left indent, right indent.
- EdgeKind.CLOSE_LINE - bottom spacing.
- Note: Alignment will be handled in the layout algorithm in a next revision.
- Extend Atom class functionality with paragraph related attributes:
- Testing
- TextParagraphDemo added for checking the correct behavior of paragraph functionality. [3424] [3433]
- Unit testing: LayoutBuilderTest - updated in [3386]
Implementation
- Initial implementation in branch branches/private/vlado/paragraph-changes.
- Merged implementation in branch branches/private/vlado/merge-text-tasks.
- Known issue - indentation does not work for the first paragraph. To be corrected in the next revision after fixing the initializing text.
Testing
(Place the testing results here.)
Comments
(Write comments for this or later revisions here.)