return;
}
final boolean overflowX = paragraph.getStaticBoxLayoutProperties().isOverflowX();
RenderNode node = paragraph.getFirstChild();
ParagraphPoolBox prev = null;
while (node != null)
{
// all childs of the linebox container must be inline boxes. They
// represent the lines in the paragraph. Any other element here is
// a error that must be reported
if (node.getNodeType() != LayoutNodeTypes.TYPE_BOX_LINEBOX)
{
throw new IllegalStateException("Encountered " + node.getClass());
}
final ParagraphPoolBox inlineRenderBox = (ParagraphPoolBox) node;
// Process the current line.
final long y = inlineRenderBox.getCachedY();
final long height = inlineRenderBox.getCachedHeight();
if (y + height <= paragraphBottom)
{
// Node will fit, so we can allow it ..
prev = inlineRenderBox;
node = node.getNext();
continue;
}
// Encountered a line that will not fully fit into the paragraph.
// Merge it with the previous line-paragraph.
final ParagraphPoolBox mergedLine = rebuildLastLine(prev, inlineRenderBox);
// now remove all pending lineboxes (they should be empty anyway).
while (node != null)
{
final RenderNode oldNode = node;
node = node.getNext();
paragraph.remove(oldNode);
}
if (mergedLine == null)
{
return;
}
final ElementAlignment textAlignment = paragraph.getLastLineAlignment();
final LastLineTextAlignmentProcessor proc = create(textAlignment);
// Now Build the sequence list that holds all nodes for the horizontal alignment computation.
// The last line will get a special "last-line" horizontal alignment. This is quite usefull if
// we are working with justified text and want the last line to be left-aligned.
final SequenceList sequenceList = createHorizontalSequenceList(mergedLine);
final long lineStart = paragraph.getContentAreaX1();
final long lineEnd;
if (overflowX)
{
lineEnd = OVERFLOW_DUMMY_WIDTH;
}
else
{
lineEnd = paragraph.getContentAreaX2();
}
if (lineEnd - lineStart <= 0)
{
final long minimumChunkWidth = paragraph.getMinimumChunkWidth();
proc.initialize(metaData, sequenceList, lineStart, lineStart + minimumChunkWidth, pageGrid, overflowX);
logger.warn("Auto-Corrected zero-width linebox."); // NON-NLS
}
else
{
proc.initialize(metaData, sequenceList, lineStart, lineEnd, pageGrid, overflowX);
}
proc.performLastLineAlignment();
proc.deinitialize();
// Now Perform the vertical layout for the last line of the paragraph.
final BoxAlignContext valignContext = createVerticalAlignContext(mergedLine);
final StaticBoxLayoutProperties blp = mergedLine.getStaticBoxLayoutProperties();
final BoxDefinition bdef = mergedLine.getBoxDefinition();
final long insetTop = (blp.getBorderTop() + bdef.getPaddingTop());
final long contentAreaY1 = mergedLine.getCachedY() + insetTop;
final long lineHeight = mergedLine.getLineHeight();
verticalAlignmentProcessor.align(valignContext, contentAreaY1, lineHeight);
// And finally make sure that the paragraph box itself obeys to the defined vertical box alignment.
performVerticalBlockAlignment(paragraph);
return;