Skip to content

Commit 2237853

Browse files
committed
Cover several layout classes with documentation
DEVSIX-6675
1 parent b406203 commit 2237853

File tree

13 files changed

+148
-2
lines changed

13 files changed

+148
-2
lines changed

layout/src/main/java/com/itextpdf/layout/element/AbstractElement.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,5 +190,10 @@ public T setPageNumber(int pageNumber) {
190190
return (T) (Object) this;
191191
}
192192

193+
/**
194+
* Creates new renderer instance.
195+
*
196+
* @return new {@link IRenderer}
197+
*/
193198
protected abstract IRenderer makeNewRenderer();
194199
}

layout/src/main/java/com/itextpdf/layout/element/Cell.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,15 @@ protected IRenderer makeNewRenderer() {
228228
return new CellRenderer(this);
229229
}
230230

231+
/**
232+
* Updates cell indexes.
233+
*
234+
* @param row the number of the row to update
235+
* @param col the number of the col to update
236+
* @param numberOfColumns to evaluate new colspan
237+
*
238+
* @return this {@link Cell} with updated fields
239+
*/
231240
protected Cell updateCellIndexes(int row, int col, int numberOfColumns) {
232241
this.row = row;
233242
this.col = col;

layout/src/main/java/com/itextpdf/layout/element/FlexContainer.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,14 @@ This file is part of the iText (R) project.
4545
import com.itextpdf.layout.renderer.FlexContainerRenderer;
4646
import com.itextpdf.layout.renderer.IRenderer;
4747

48+
/**
49+
* A {@link FlexContainer} represents a container of the flex objects.
50+
*/
4851
class FlexContainer extends Div {
4952

53+
/**
54+
* Creates new {@link FlexContainer} instance.
55+
*/
5056
public FlexContainer() {
5157
super();
5258
}

layout/src/main/java/com/itextpdf/layout/element/IBlockElement.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,10 @@ This file is part of the iText (R) project.
4242
*/
4343
package com.itextpdf.layout.element;
4444

45+
/**
46+
* This class represents a block layout element with special margins, tabbing, and alignment.
47+
* An {@link IBlockElement} will try to take up as much horizontal space as available to it
48+
* on the canvas or page. The concept is comparable to the block element in HTML.
49+
*/
4550
public interface IBlockElement extends IAbstractElement {
4651
}

layout/src/main/java/com/itextpdf/layout/element/TabStop.java

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,30 +100,69 @@ public TabStop(float tabPosition, TabAlignment tabAlignment, ILineDrawer tabLead
100100
this.tabAnchor = '.';
101101
}
102102

103+
/**
104+
* Returns the position of a tab stop.
105+
*
106+
* @return tabPosition, measured in absolute points
107+
*/
103108
public float getTabPosition() {
104109
return tabPosition;
105110
}
106111

112+
/**
113+
* Returns the alignment of a tab stop, which defines the way the textual content
114+
* should be positioned in regard to this tab stop.
115+
*
116+
* @return a {@link TabAlignment} value
117+
*/
107118
public TabAlignment getTabAlignment() {
108119
return tabAlignment;
109120
}
110121

122+
/**
123+
* Sets the alignment, which defines the way the textual content
124+
* should be positioned in regard to this tab stop.
125+
*
126+
* @param tabAlignment a {@link TabAlignment} value
127+
*/
111128
public void setTabAlignment(TabAlignment tabAlignment) {
112129
this.tabAlignment = tabAlignment;
113130
}
114131

132+
/**
133+
* Returns the anchor of a tab stop.
134+
*
135+
* @return a {@link Character} value
136+
*/
115137
public Character getTabAnchor() {
116138
return tabAnchor;
117139
}
118140

141+
/**
142+
* Sets the anchor of a tab stop.
143+
*
144+
* @param tabAnchor a {@link Character} value
145+
*/
119146
public void setTabAnchor(Character tabAnchor) {
120147
this.tabAnchor = tabAnchor;
121148
}
122149

150+
/**
151+
* Returns the tab leader of a tab stop, which defines a pattern that
152+
* should be repeated until the TabStop is reached.
153+
*
154+
* @return a {@link ILineDrawer} value, a pattern drawing object
155+
*/
123156
public ILineDrawer getTabLeader() {
124157
return tabLeader;
125158
}
126159

160+
/**
161+
* Sets the tab leader of a tab stop, which defines a pattern that
162+
* should be repeated until the TabStop is reached.
163+
*
164+
* @param tabLeader a {@link ILineDrawer} value
165+
*/
127166
public void setTabLeader(ILineDrawer tabLeader) {
128167
this.tabLeader = tabLeader;
129168
}

layout/src/main/java/com/itextpdf/layout/element/Table.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,6 @@ public Table setSkipLastFooter(boolean skipLastFooter) {
525525
* @param caption The element to be set as a caption.
526526
* @return this element
527527
*/
528-
529528
public Table setCaption(Div caption) {
530529
this.caption = caption;
531530
if (null != caption) {
@@ -941,6 +940,11 @@ private static UnitValue[] normalizeColumnWidths(int numberOfColumns) {
941940
return normalized;
942941
}
943942

943+
/**
944+
* Returns the list of all row groups.
945+
*
946+
* @return a list of a {@link RowRange} which holds the row numbers of a section of a table
947+
*/
944948
protected java.util.List<RowRange> getRowGroups() {
945949
int lastRowWeCanFlush = currentColumn == columnWidths.length ? currentRow : currentRow - 1;
946950
int[] cellBottomRows = new int[columnWidths.length];

layout/src/main/java/com/itextpdf/layout/hyphenation/HyphenationConstants.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ This file is part of the iText (R) project.
4242
*/
4343
package com.itextpdf.layout.hyphenation;
4444

45+
/**
46+
* Class containing constants to be used in hyphenation on layout level.
47+
*/
4548
public class HyphenationConstants {
4649

4750
public static final String HYPHENATION_DEFAULT_RESOURCE = "com/itextpdf/hyph/";

layout/src/main/java/com/itextpdf/layout/hyphenation/TernaryTreeIterator.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ public Item(char p, char c) {
9292
child = c;
9393
}
9494

95+
/**
96+
* Construct item.
97+
*
98+
* @param i an {@link Item}
99+
*/
95100
public Item(Item i) {
96101
this.parent = i.parent;
97102
this.child = i.child;

layout/src/main/java/com/itextpdf/layout/renderer/AreaBreakRenderer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ This file is part of the iText (R) project.
5252
import java.util.List;
5353

5454
/**
55-
* Renderer object for the {@link AreaBreak} layout element. Will terminate the
55+
* Renderer for the {@link AreaBreak} layout element. Will terminate the
5656
* current content area and initialize a new one.
5757
*/
5858
public class AreaBreakRenderer implements IRenderer {

layout/src/main/java/com/itextpdf/layout/renderer/BlockRenderer.java

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,16 @@ This file is part of the iText (R) project.
8282
import java.util.Map;
8383
import java.util.Set;
8484

85+
/**
86+
* Represents a renderer for block elements.
87+
*/
8588
public abstract class BlockRenderer extends AbstractRenderer {
8689

90+
/**
91+
* Creates a BlockRenderer from its corresponding layout object.
92+
*
93+
* @param modelElement the {@link IElement} which this object should manage
94+
*/
8795
protected BlockRenderer(IElement modelElement) {
8896
super(modelElement);
8997
}
@@ -583,6 +591,13 @@ public Rectangle getOccupiedAreaBBox() {
583591
return bBox;
584592
}
585593

594+
/**
595+
* Creates a split renderer.
596+
*
597+
* @param layoutResult the result of content layouting
598+
*
599+
* @return a new {@link AbstractRenderer} instance
600+
*/
586601
protected AbstractRenderer createSplitRenderer(int layoutResult) {
587602
AbstractRenderer splitRenderer = (AbstractRenderer) getNextRenderer();
588603
splitRenderer.parent = parent;
@@ -593,6 +608,13 @@ protected AbstractRenderer createSplitRenderer(int layoutResult) {
593608
return splitRenderer;
594609
}
595610

611+
/**
612+
* Creates an overflow renderer.
613+
*
614+
* @param layoutResult the result of content layouting
615+
*
616+
* @return a new {@link AbstractRenderer} instance
617+
*/
596618
protected AbstractRenderer createOverflowRenderer(int layoutResult) {
597619
AbstractRenderer overflowRenderer = (AbstractRenderer) getNextRenderer();
598620
overflowRenderer.parent = parent;
@@ -645,6 +667,10 @@ AbstractRenderer[] createSplitAndOverflowRenderers(int childPos, int layoutStatu
645667
return new AbstractRenderer[]{splitRenderer, overflowRenderer};
646668
}
647669

670+
/**
671+
* This method applies vertical alignment for the occupied area
672+
* of the renderer and its children renderers.
673+
*/
648674
protected void applyVerticalAlignment() {
649675
VerticalAlignment verticalAlignment = this.<VerticalAlignment>getProperty(Property.VERTICAL_ALIGNMENT);
650676
if (verticalAlignment == null || verticalAlignment == VerticalAlignment.TOP || childRenderers.isEmpty()) {
@@ -692,6 +718,12 @@ protected void applyVerticalAlignment() {
692718
}
693719
}
694720

721+
/**
722+
* This method rotates content of the renderer and
723+
* calculates correct occupied area for the rotated element.
724+
*
725+
* @param layoutBox a {@link Rectangle}
726+
*/
695727
protected void applyRotationLayout(Rectangle layoutBox) {
696728
float angle = (float) this.getPropertyAsFloat(Property.ROTATION_ANGLE);
697729

@@ -775,6 +807,11 @@ protected AffineTransform createRotationTransformInsideOccupiedArea() {
775807
return rotationTransform;
776808
}
777809

810+
/**
811+
* This method starts rotation for the renderer if rotation angle property is specified.
812+
*
813+
* @param canvas the {@link PdfCanvas} to draw on
814+
*/
778815
protected void beginRotationIfApplied(PdfCanvas canvas) {
779816
Float angle = this.getPropertyAsFloat(Property.ROTATION_ANGLE);
780817
if (angle != null) {
@@ -790,6 +827,11 @@ protected void beginRotationIfApplied(PdfCanvas canvas) {
790827
}
791828
}
792829

830+
/**
831+
* This method ends rotation for the renderer if applied.
832+
*
833+
* @param canvas the {@link PdfCanvas} to draw on
834+
*/
793835
protected void endRotationIfApplied(PdfCanvas canvas) {
794836
Float angle = this.getPropertyAsFloat(Property.ROTATION_ANGLE);
795837
if (angle != null && hasOwnProperty(Property.ROTATION_INITIAL_HEIGHT)) {

0 commit comments

Comments
 (0)