Last modified 16 years ago
Last modified on 07/04/09 17:44:56
Analysis
Overview
User should be able to specify alignment of specific paragraph directly into the paragraph HUD.
Available values should be:
- Left
- Right
- Center
- Justified
Task requirements
- Provide to the user the ability to manage paragraph alignment. Add easy to use controls in the paragraph settings hud.
- Implement left and justified alignment. Right and center alignment remain as optional.
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
- Add word break functionality in the layout to allow alignment manipulation.
- Add white space extra handling in the layout to be used in justified alignment. For justified option the white spaces between words should be extended so that the lines are aligned both sides.
- Add alignment badness calculation.
Related
TEXT_PARAGPRAPH_FORMAT_COMMONS_R0
TEXT_PARAGRAPH_SPACING_R0
TEXT_PARAGRAPH_STYLE_TEMPLATES_R0
TEXT_PARAGRAPH_CHAR_STYLE_R0
TEXT_PARAGRAPH_NEXT_STYLE_R0
TEXT_HALO_MENU_R0
DETACHED_TEXT_FRAME_EDITOR_R0
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 alignment controls.
Design
- Add Badness.addBrokenWord to consider the word breaks when calculating badness value.
- Modify EdgeKind.SEGMENT to handle:
- the case of word breaks.
- Vertex.WHITE_SPACE_EXTRA value which adds white space to space separators in the text (needed for justified alignment).
- When the currently handled word from the text can not fit into the line that the algorithm is processing, the algorithm's modifications are as follows:
- Badness of SEGMENT should be higher than Badness of CLOSE_LINE (thus, flowing the current word on a new line).
- If left alignment is chosen no further changes are needed.
- If justified alignment is chosen
- Get all previous SEGMENTs until OPEN_LINE is reached (using Vertex.LAST_EDGE vertex field).
- Calculate the extra space (WHITE_SPACE_EXTRA) that has to be added: (white space extra) = (space left on the line) / (number of previous SEGMENTs on the line) - 1.
- Modify BASE_POINT vertex field for each of the SEGMENTs on the line, relative to the extra white spaces for all previous SEGMENTs (that is, shift the segments with some extra space to the right).
- Add a paragraph halo and hud (TextParagraphHud class)
- Follow the UI specified in TEXT_PARAGRAPH_SPACING_R0
- For now add only alignment controls.
- Move the First line indent control from TextFontHud to TextParagraphHud.
Implementation
(Describe and link the implementation results here (from the wiki or the repository).)
Testing
(Place the testing results here.)
Comments
(Write comments for this or later revisions here.)