[[BackLinksMenu]]

[[TicketQuery(summary=TEXT_PARAGRAPH_SPACING_R0, format=table, col=summary|owner|status|type|component|priority|effort|importance, rows=description|analysis_owners|analysis_reviewers|analysis_score|design_owners|design_reviewers|design_score|implementation_owners|implementation_reviewers|implementation_score|test_owners|test_reviewers|test_score|)]]

= 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.[[BR]]
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.
[[Image(source:trunk/sophie2-platform/doc/spec-diagrams/Paragraph.png, 50%)]]
== 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 [[wiki: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 [[Image(source:trunk/sophie2-platform/doc/spec-diagrams/ParagraphHaloAndHud.png, 50%)]]

== Related ==
[[wiki:TEXT_PARAGPRAPH_FORMAT_COMMONS_R0]][[BR]]
[[wiki:TEXT_PARAGRAPH_ALIGN_R0]][[BR]]
[[wiki:TEXT_PARAGRAPH_STYLE_TEMPLATES_R0]][[BR]]
[[wiki:TEXT_PARAGRAPH_CHAR_STYLE_R0]][[BR]]
[[wiki:TEXT_PARAGRAPH_NEXT_STYLE_R0]][[BR]][[BR]]
[[wiki: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.
 * Testing
  * TextParagraphDemo added for checking the correct behavior of paragraph functionality.
    [3424]
    [3433]
  * Unit testing: [http://www.sophie2.org/trac/browser/branches/private/nenko/nenko2/modules/org.sophie2.base.model.text/src/test/java/org/sophie2/base/model/text/layout/LayoutBuilderTest.java LayoutBuilderTest] - updated in [3386]

= Implementation =
 * Implementation in branch [http://www.sophie2.org/trac/browser/branches/private/vlado/paragraph-changes branches/private/vlado/paragraph-changes].
  * [3781]
  * [3838]
  * [3839]
  * [3862]
  * Other changesets are not relevant.
 * 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.)